ALICE 1.3  1.0
Develpoer documentation
alice-desktop-1.3.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 #
4 # ADALM1000 alice-desktop 1.3.py(w) (1-3-2022)
5 # For Python version 2.7 or 3.7, Windows OS and Linux OS
6 # With external module pysmu ( libsmu >= 1.0.2 for ADALM1000 )
7 # optional split I/O modes for Rev F hardware supported
8 # Uses new firmware (2.17 or >) that support control of ADC mux configure
9 # Created by D Mercer ()
10 #
11 #
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 #
21 # If runing from source you can un-comment the following to include pyplot
22 try:
23  from matplotlib import pyplot as plt
24  matplot_found = True
25 except:
26  matplot_found = False
27 #
28 import csv
29 import wave
30 import os
31 #import requests
32 import sys
33 import struct
34 import subprocess
35 from time import gmtime, strftime
36 # Check to see if user passed init file name on command line
37 if len(sys.argv) > 1:
38  InitFileName = str(sys.argv[1])
39  print( 'Init file name: ' + InitFileName )
40 else:
41  InitFileName = 'alice_init.ini'
42 
43 if sys.version_info[0] == 2:
44  print ("Python 2.x")
45  import urllib2
46  import tkFont
47  from Tkinter import *
48  from ttk import *
49  from tkFileDialog import askopenfilename
50  from tkFileDialog import asksaveasfilename
51  from tkSimpleDialog import askstring
52  from tkMessageBox import *
53 if sys.version_info[0] == 3:
54  print ("Python 3.x")
55  import urllib.request, urllib.error, urllib.parse
56  from tkinter.font import *
57  from tkinter import *
58  from tkinter.ttk import *
59  from tkinter.filedialog import askopenfilename
60  from tkinter.filedialog import asksaveasfilename
61  from tkinter.simpledialog import askstring
62  from tkinter.messagebox import *
63 #
64 import webbrowser
65 try:
66  from pysmu import *
67  pysmu_found = True
68 except:
69  pysmu_found = False
70 #
71 # check which operating system
72 import platform
73 #
74 RevDate = "3 Jan 2022"
75 SWRev = "1.3 "
76 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.12/alice-desktop-1.3-setup.exe'
77 # small bit map of ADI logo for window icon
78 TBicon = """
79 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
80 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
81 i8fUAgA7
82 """
83 
84 root=Tk()
85 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
86 img = PhotoImage(data=TBicon)
87 root.call('wm', 'iconphoto', root._w, '-default', img)
88 print("Windowing System is " + str(root.tk.call('tk', 'windowingsystem')))
89 
90 GRW = 720 # Width of the time grid 720 default
91 GRH = 390 # Height of the time grid 390 default
92 X0L = 55 # Left top X value of time grid
93 Y0T = 25 # Left top Y value of time grid
94 #
95 GRWF = 720 # Width of the spectrum grid 720 default
96 GRHF = 390 # Height of the spectrum grid 390 default
97 X0LF = 45 # Left top X value of spectrum grid
98 Y0TF = 25 # Left top Y value of spectrum grid
99 #
100 GRWBP = 720 # Width of the Bode Plot grid 720 default
101 GRHBP = 390 # Height of the Bode Plot grid 390 default
102 X0LBP = 45 # Left top X value of Bode Plot grid
103 Y0TBP = 25 # Left top Y value of Bode Plot grid
104 #
105 GRWXY = 420 # Width of the XY grid 420 default
106 GRHXY = 390 # Height of the XY grid 390 default
107 X0LXY = 55 # Left top X value of XY grid
108 Y0TXY = 25 # Left top Y value of XY grid
109 #
110 GRWIA = 400 # Width of the grid 400 default
111 GRHIA = 400 # Height of the grid 400 default
112 X0LIA = 37 # Left top X value of grid
113 Y0TIA = 25 # Left top Y value of grid
114 #
115 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
116 GRHNqP = 400 # Height of the grid 400 default
117 X0LNqP = 25 # Left top X value of grid
118 Y0TNqP = 25 # Left top Y value of grid
119 #
120 GRWNiC = 400 # Width of the Nichols plot grid 400 default
121 GRHNiC = 400 # Height of the grid 400 default
122 X0LNiC = 25 # Left top X value of grid
123 Y0TNiC = 25 # Left top Y value of grid
124 #
125 GRWPhA = 400 # Width of the grid 400 default
126 GRHPhA = 400 # Height of the grid 400 default
127 X0LPhA = 37 # Left top X value of grid
128 Y0TPhA = 25 # Left top Y value of grid
129 #
130 FontSize = 8
131 BorderSize = 1
132 MouseX = MouseY = -10
133 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
134 
135 COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
136 COLORcanvas = "#000000" # 100% black
137 COLORgrid = "#808080" # 50% Gray
138 COLORzeroline = "#0000ff" # 100% blue
139 COLORtrace1 = "#00ff00" # 100% green
140 COLORtrace2 = "#ff8000" # 100% orange
141 COLORtrace3 = "#00ffff" # 100% cyan
142 COLORtrace4 = "#ffff00" # 100% yellow
143 COLORtrace5 = "#ff00ff" # 100% magenta
144 COLORtrace6 = "#C80000" # 90% red
145 COLORtrace7 = "#8080ff" # 100% purple
146 COLORtraceR1 = "#008000" # 50% green
147 COLORtraceR2 = "#905000" # 50% orange
148 COLORtraceR3 = "#008080" # 50% cyan
149 COLORtraceR4 = "#808000" # 50% yellow
150 COLORtraceR5 = "#800080" # 50% magenta
151 COLORtraceR6 = "#800000" # 80% red
152 COLORtraceR7 = "#4040a0" # 80% purple
153 COLORtext = "#ffffff" # 100% white
154 COLORtrigger = "#ff0000" # 100% red
155 COLORsignalband = "#ff0000" # 100% red
156 ButtonGreen = "#00ff00" # 100% green
157 ButtonRed = "#ff0000" # 100% red
158 GUITheme = "Light"
159 ButtonOrder = 0
160 SBoxarrow = 11
161 Closed = 0
162 ColorMode = IntVar(0)
163 # # Can be Light or Dark or Blue or LtBlue or Custom where:
164 FrameBG = "#d7d7d7" # Background color for frame
165 ButtonText = "#000000" # Button Text color
166 # Widget relief can be RAISED, GROOVE, RIDGE, and FLAT
167 ButRelief = RAISED
168 LabRelief = FLAT
169 FrameRefief = RIDGE
170 LocalLanguage = "English"
171 
172 OnBoardRes = 50.83
173 AD584act = 2.5
174 # Set sample buffer size
175 HoldOff = 0.0
176 LShift = 0
177 BaseSampleRate = 100000
178 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
179 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
180 MinSamples = 2000
181 MaxSamples = 200000
182 ETSrecord = 2000
183 AWGRecLength = 32768
184 DISsamples = GRW
185 First_Slow_sweep = 0
186 Slow_Sweep_Limit = 200
187 # set initial trigger conditions
188 TRIGGERlevel = 2.5 # Triggerlevel in volts
189 
190 MathString = "VBuffA[t] + VBuffB[t]"
191 MathUnits = " V"
192 MathXString = "VBuffA[t]"
193 MathXUnits = " V"
194 MathYString = "VBuffB[t]"
195 MathYUnits = " V"
196 UserAString = "MaxV1-VATop"
197 UserALabel = "OverShoot"
198 UserBString = "MinV2-VBBase"
199 UserBLabel = "UnderShoot"
200 MathAxis = "V-A"
201 MathXAxis = "V-A"
202 MathYAxis = "V-B"
203 AWGAMathString = "(VBuffA + VBuffB)/2"
204 AWGBMathString = "(VBuffA + VBuffB)/2"
205 AWGAcsvFile = "examplea.csv"
206 AWGBcsvFile = "exampleb.csv"
207 AWGAwavFile = "examplea.wav"
208 AWGBwavFile = "exampleb.wav"
209 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
210 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
211 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
212 AWGFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
213 AWGFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
214 ChaMeasString1 = "DCV1"
215 ChaMeasString2 = "DCI1"
216 ChaMeasString3 = "SV1"
217 ChaMeasString4 = "MaxV1-MinV1"
218 ChaMeasString5 = "MaxI1-MinI1"
219 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
220 ChbMeasString1 = "DCV2"
221 ChbMeasString2 = "DCI2"
222 ChbMeasString3 = "SV2"
223 ChbMeasString4 = "MaxV2-MinV2"
224 ChbMeasString5 = "MaxI2-MinI2"
225 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
226 ChaLableSrring1 = "CHA-DCV "
227 ChaLableSrring2 = "CHA-DCI "
228 ChaLableSrring3 = "CHA-TRMS "
229 ChaLableSrring4 = "CHA-VP-P "
230 ChaLableSrring5 = "CHA-IP-P "
231 ChaLableSrring6 = "CHA-ACRMS "
232 ChbLableSrring1 = "CHB-DCV "
233 ChbLableSrring2 = "CHB-DCI "
234 ChbLableSrring3 = "CHB-TRMS "
235 ChbLableSrring4 = "CHB-VP-P "
236 ChbLableSrring5 = "CHB-IP-P "
237 ChbLableSrring6 = "CHB-ACRMS "
238 LabelPlotText = IntVar(0)
239 PlotLabelText = "Custom Plot Label"
240 
241 GridWidth = IntVar(0)
242 GridWidth.set(1)
243 TRACEwidth = IntVar(0)
244 TRACEwidth.set(1)
245 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
246 TRACEaverage.set(8)
247 Vdiv = IntVar(0)
248 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
249 LPFTrigger = IntVar(0) # trigger lpf on/off
250 Trigger_LPF_length = IntVar(0)
251 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
252 HarmonicMarkers = IntVar(0)
253 HarmonicMarkers.set(3)
254 AWGShowAdvanced = IntVar(0)
255 AWGShowAdvanced.set(0)
256 AWG_Amp_Mode = IntVar(0)
257 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
258 AWGA_Ext_Gain = DoubleVar(0)
259 AWGA_Ext_Gain.set(1.0)
260 AWGA_Ext_Offset = DoubleVar(0)
261 AWGA_Ext_Offset.set(0.0)
262 AWGB_Ext_Gain = DoubleVar(0)
263 AWGB_Ext_Gain.set(1.0)
264 AWGB_Ext_Offset = DoubleVar(0)
265 AWGB_Ext_Offset.set(0.0)
266 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
267 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
268 Two_X_Sample.set(0)
269 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
270 ADC_Mux_Mode.set(0)
271 Last_ADC_Mux_Mode = 0
272 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
273 Alternate_Sweep_Mode.set(0)
274 #
275 ChopModeFilter = [0.25, 0.25, 0.25, 0.25] # [0.25, 0.25, 0.25, 0.25]
276 # ChopModeFilter = [0, 1, 2, 3, 4, 3, 2, 1, 0]
277 # ChopModeFilter = numpy.array(ChopModeFilter) / 16
278 Roll_Mode = IntVar(0) # select roll sweep (slow) mode
279 Roll_Mode.set(0)
280 #
281 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
282 ZEROstuffing.set(1)
283 FFTwindow = IntVar(0) # FFT window function variable
284 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
285  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
286 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
287 RelPhaseCenter = IntVar(0)
288 RelPhaseCenter.set(0) # Center line value for phase plots
289 ImpedanceCenter = IntVar(0)
290 ImpedanceCenter.set(0) # Center line value for impedance plots
291 MultipleBoards = IntVar(0)
292 MultipleBoards.set(0) # Turn on access for multiple m1k boards
293 IgnoreFirmwareCheck = 0
294 EnableScopeOnly = 0
295 EnableXYPlotter = 1
296 EnablePhaseAnalizer = 1
297 EnableSpectrumAnalizer = 1
298 EnableBodePlotter = 1
299 EnableImpedanceAnalizer = 1
300 EnableOhmMeter = 1
301 EnableDigIO = 1
302 EnableCommandInterface = 0
303 EnableMuxMode = 0
304 EnablePIODACMode = 0
305 EnableMinigenMode = 0
306 EnablePmodDA1Mode = 0
307 EnableDigPotMode = 0
308 EnableGenericSerialMode = 0
309 EnableAD5626SerialMode = 0
310 EnableDigitalFilter = 0
311 EnableMeasureScreen = 0
312 EnableETSScreen = 0
313 EnableHSsampling = 0
314 EnableUserEntries = 0
315 AllowFlashFirmware = 0
316 DeBugMode = 0
317 ShowTraceControls = 0
318 # ADC Mux defaults
319 v1_adc_conf = 0x20F1
320 i1_adc_conf = 0x20F7
321 v2_adc_conf = 0x20F7
322 i2_adc_conf = 0x20F1
323 #
324 MouseFocus = 1
325 HistAsPercent = 0
326 ShowBallonHelp = 0
327 contloop = 0
328 discontloop = 0
329 AwgLayout = "Horz"
330 MarkerLoc = 'UL' # can be UL, UR, LL or LR
331 CHA_TC1 = DoubleVar(0)
332 CHA_TC1.set(1)
333 CHA_TC2 = DoubleVar(0)
334 CHA_TC2.set(1)
335 CHB_TC1 = DoubleVar(0)
336 CHB_TC1.set(1)
337 CHB_TC2 = DoubleVar(0)
338 CHB_TC2.set(1)
339 CHA_A1 = DoubleVar(0)
340 CHA_A1.set(1)
341 CHA_A2 = DoubleVar(0)
342 CHA_A2.set(1)
343 CHB_A1 = DoubleVar(0)
344 CHB_A1.set(1)
345 CHB_A2 = DoubleVar(0)
346 CHB_A2.set(1)
347 Auto_ETS_Comp = IntVar(0)
348 ETS_TC1 = DoubleVar(0)
349 ETS_TC1.set(0.18333)
350 ETS_A1 = DoubleVar(0)
351 ETS_A1.set(5.0)
352 ETS_TC2 = DoubleVar(0)
353 ETS_TC2.set(0.03)
354 ETS_A2 = DoubleVar(0)
355 ETS_A2.set(5.0)
356 PhaseOffset1x = 37
357 PhaseOffset2x = 37
358 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
359 # 'aqua' built-in native Mac OS X only; Native Mac OS X
360 windowingsystem = root.tk.call('tk', 'windowingsystem')
361 ScreenWidth = root.winfo_screenwidth()
362 ScreenHeight = root.winfo_screenheight()
363 # print(str(ScreenWidth) + "X" + str(ScreenHeight))
364 if (root.tk.call('tk', 'windowingsystem')=='aqua'):
365  Style_String = 'aqua'
366  # On Macs, allow the dock icon to deiconify.
367  root.createcommand('::tk::mac::ReopenApplication', root.deiconify)
368  root.createcommand('::tk::mac::Quit', root.destroy)# Bcloseexit)
369  # On Macs, set up menu bar to be minimal.
370  root.option_add('*tearOff', False)
371  if sys.version_info[0] == 2:
372  menubar = tKinter.Menu(root)
373  appmenu = tKinter.Menu(menubar, name='apple')
374  else:
375  menubar = tkinter.Menu(root)
376  appmenu = tkinter.Menu(menubar, name='apple')
377  # menubar = tk.Menu(root)
378  # appmenu = tk.Menu(menubar, name='apple')
379  menubar.add_cascade(menu=appmenu)
380  # appmenu.add_command(label='Exit', command=Bcloseexit)
381  root['menu'] = menubar
382 else:
383  Style_String = 'alt'
384 # Check if there is an alice_init.ini file to read in
385 try:
386  import alice
387  import pathlib
388 # pathlib only available as standard in Python 3.4 and higher. For Python 2.7 must manually install package
389  path = pathlib.Path(alice.__file__).parent.absolute()
390  filename = os.path.join(path, "resources", InitFileName) # "alice_init.ini")
391  InitFile = open(filename)
392  for line in InitFile:
393  try:
394  exec( line.rstrip(), globals(), globals())
395  #exec( line.rstrip() )
396  except:
397  print("Skiping " + line.rstrip())
398  InitFile.close()
399 except:
400  try:
401  InitFile = open(InitFileName) # "alice_init.ini"
402  for line in InitFile:
403  try:
404  exec( line.rstrip(), globals(), globals())
405  #exec( line.rstrip() )
406  except:
407  print("Skiping " + line.rstrip())
408  InitFile.close()
409  except:
410  print( "No Init File Read. " + InitFileName + " Not Found")
411 #
412 XOLXY = X0L = FontSize * 7
413 XOLF = XOLBP = XOLIA = int(FontSize * 4.625)
414 XOLNqP = XOLNiC = int(FontSize * 3.125)
415 root.style = Style()
416 try:
417  root.style.theme_use(Style_String)
418 except:
419  root.style.theme_use('default')
420 if MouseFocus == 1:
421  root.tk_focusFollowsMouse()
422 #
423 DevID = "m1k"
424 #
425 if sys.version_info[0] == 2:
426  default_font = tkFont.nametofont("TkDefaultFont")
427 if sys.version_info[0] == 3:
428  default_font = tkinter.font.nametofont("TkDefaultFont")
429 default_font.configure(size=FontSize)
430 
431 CHvpdiv = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0)
432 
433 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
434 
435 SAMagdiv = ("10nV", "100nV", "1uV", "10uV", "100uV", "1mV", "10mV", "0.1", "1.0", "10.0")
436 
437 TMpdiv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
438 ResScalediv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000)
439 SampRateList = (1024, 2048, 4096, 8192, 16384, 32765, 64000, 93023, 93385, 93750, 94118,
440  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
441 NoiseList =[ "None", "Uniform", "Gaussian"]
442 TIMEdiv = 0.5
443 RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
444 
445 
446 AWGAAmplvalue = 0.0
447 AWGAOffsetvalue = 0.0
448 AWGAFreqvalue = 0.0
449 AWGAPhasevalue = 0
450 AWGAdelayvalue = 0
451 AWGADutyCyclevalue = 50
452 AWGAWave = 'dc'
453 AWGBAmplvalue = 0.0
454 AWGBOffsetvalue = 0.0
455 AWGBFreqvalue = 0.0
456 AWGBPhasevalue = 0
457 AWGBdelayvalue = 0
458 AWGBDutyCyclevalue = 50
459 AWGBWave = 'dc'
460 AWGACycles = 1
461 AWGBCycles = 1
462 AWGABurstDelay = 0
463 AWGBBurstDelay = 0
464 Reset_Freq = 300
465 MeasGateLeft = 0.0
466 MeasGateRight = 0.0 # in mSec
467 MeasGateNum = 0
468 MeasGateStatus = IntVar(0)
469 MeasGateStatus.set(0)
470 #
471 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
472 
473 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
474 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
475 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
476 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
477 PeakVA = PeakVB = PeakIA = PeakIB = 0.0
478 PeakVMA = PeakVMB = PeakVMC = PeakVMD = 0.0
479 PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
480 PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = 0.0
481 PeakphaseVA = PeakphaseVB = PeakphaseIA = PeakphaseIB = PeakphaseVAB = 0.0
482 CHADCy = CHBDCy = 0
483 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
484 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
485 # Calibration coefficients
486 CHAVGain = CHBVGain = 1.0
487 CHAVOffset = CHBVOffset = 0.0
488 # Initialisation of general variables
489 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
490 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
491 # Other global variables required in various routines
492 CANVASwidth = GRW + 2 * X0L # The canvas width
493 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
494 
495 ADsignal1 = [] # Ain signal array channel A and B
496 VBuffA = []
497 VBuffB = []
498 IBuffA = []
499 IBuffB = []
500 VBuffMA = []
501 VBuffMB = []
502 VBuffMC = []
503 VBuffMD = []
504 VmemoryMuxA = []
505 VmemoryMuxB = []
506 VmemoryMuxC = []
507 VmemoryMuxD = []
508 #
509 DBuff0 = []
510 DBuff1 = []
511 DBuff2 = []
512 DBuff3 = []
513 #
514 VAresult = []
515 VBresult = []
516 IAresult = []
517 IBresult = []
518 PhaseIA = []
519 PhaseIB = []
520 PhaseVA = []
521 PhaseVB = []
522 DFiltACoef = [1]
523 DFiltBCoef = [1]
524 DigFiltA = IntVar(0)
525 DigFiltA.set(0)
526 DigFiltABoxCar = IntVar(0)
527 DigFiltBBoxCar = IntVar(0)
528 DigDeSkewA = IntVar(0)
529 DigDeSkewB = IntVar(0)
530 DigFiltB = IntVar(0)
531 DigFiltB.set(0)
532 DigBuffA = IntVar(0)
533 DigBuffB = IntVar(0)
534 DigBuffA.set(0)
535 DigBuffB.set(0)
536 AWGFiltA = IntVar(0)
537 AWGFiltB = IntVar(0)
538 AWGFiltABoxCar = IntVar(0)
539 AWGFiltBBoxCar = IntVar(0)
540 AWGFiltACoef = [1]
541 AWGFiltBCoef = [1]
542 VFilterA = {}
543 VFilterB = {}
544 SampleRateStatus = IntVar(0)
545 ETSStatus = IntVar(0)
546 ETSDisp = IntVar(0)
547 ETSDir = IntVar(0)
548 #
549 AWGAwaveform = []
550 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
551 AWGBwaveform = []
552 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
553 VmemoryA = numpy.ones(1) # The memory for averaging
554 VmemoryB = numpy.ones(1)
555 ImemoryA = numpy.ones(1) # The memory for averaging
556 ImemoryB = numpy.ones(1)
557 TRACEresetTime = True # True for first new trace, false for averageing
558 TRACEresetFreq = True # True for first new trace, false for averageing
559 AWGScreenStatus = IntVar(0)
560 
561 T1Vline = [] # Voltage Trace line channel A
562 T2Vline = [] # Voltage Trace line channel B
563 T1Iline = [] # Current Trace line channel A
564 T2Iline = [] # Current Trace line channel B
565 TMAVline = [] # Voltage Trace line MUX channel A
566 TMBVline = [] # Voltage Trace line MUX channel B
567 TMCVline = [] # Voltage Trace line MUX channel C
568 TMDVline = [] # Voltage Trace line MUX channel D
569 TMARline = [] # V reference Trace line MUX channel A
570 TMBRline = [] # V reference Trace line MUX channel B
571 TMCRline = [] # V reference line MUX channel C
572 TMDRline = [] # V reference line MUX channel D
573 XYlineVA = [] # XY Trace lines
574 XYlineVB = []
575 XYlineIA = []
576 XYlineIB = []
577 XYlineM = []
578 XYlineMX = []
579 XYlineMY = []
580 XYRlineVA = [] # XY reference trace lines
581 XYRlineVB = []
582 XYRlineIA = []
583 XYRlineIB = []
584 XYRlineM = []
585 XYRlineMX = []
586 XYRlineMY = []
587 Tmathline = [] # Time Math trace line
588 TMXline = [] # Time X math Trace line
589 TMYline = [] # Time Y math Trace line
590 T1VRline = [] # V reference Trace line channel A
591 T2VRline = [] # V reference Trace line channel B
592 T1IRline = [] # I reference Trace line channel A
593 T2IRline = [] # I reference Trace line channel B
594 TMRline = [] # Math reference Trace line
595 D0line = [] # Digital input 0 Trace line
596 D1line = [] # Digital input 1 Trace line
597 D2line = [] # Digital input 2 Trace line
598 D3line = [] # Digital input 3 Trace line
599 Triggerline = [] # Triggerline
600 Triggersymbol = [] # Trigger symbol
601 #
602 SHOWsamples = 4000 # Number of samples on the screen
603 SCstart = 0 # Start sample of the trace
604 HozPoss = 0.0
605 Is_Triggered = 0
606 #
607 TRACES = 1 # Number of traces 1 or 2
608 TRACESread = 0 # Number of traces that have been read from ALM
609 ScreenTrefresh = IntVar(0)
610 ScreenXYrefresh = IntVar(0)
611 #
612 NSteps = IntVar(0) # number of frequency sweep steps
613 NSteps.set(128)
614 LoopNum = IntVar(0)
615 LoopNum.set(1)
616 LastWindow = -1
617 LastSMPfft = 0
618 CurrentFreqX = X0LBP + 14
619 FBins = numpy.linspace(0, 50000, num=16384)
620 FStep = numpy.linspace(0, 16384, num=NSteps.get())
621 FSweepMode = IntVar(0)
622 FSweepCont = IntVar(0)
623 FStepSync = IntVar(0)
624 FSweepSync = IntVar(0)
625 ShowCA_VdB = IntVar(0) # curves to display variables
626 ShowCA_P = IntVar(0)
627 ShowCB_VdB = IntVar(0)
628 ShowCB_P = IntVar(0)
629 ShowMarkerBP = IntVar(0)
630 ShowCA_RdB = IntVar(0)
631 ShowCA_RP = IntVar(0)
632 ShowCB_RdB = IntVar(0)
633 ShowCB_RP = IntVar(0)
634 ShowMathBP = IntVar(0)
635 ShowRMathBP = IntVar(0)
636 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
637 FSweepAdB = []
638 FSweepBdB = []
639 FSweepAPh = []
640 FSweepBPh = []
641 NSweepSeriesR = []
642 NSweepSeriesX = []
643 NSweepSeriesMag = [] # in ohms
644 NSweepSeriesAng = [] # in degrees
645 NSweepParallelR = []
646 NSweepParallelC = []
647 NSweepParallelL = []
648 NSweepSeriesC = []
649 NSweepSeriesL = []
650 NetworkScreenStatus = IntVar(0)
651 BDSweepFile = IntVar(0)
652 FileSweepFreq = []
653 FileSweepAmpl = []
654 #
655 MarkerNum = MarkerFreqNum = 0
656 ShowTCur = IntVar(0)
657 ShowVCur = IntVar(0)
658 TCursor = VCursor = 0
659 ShowXCur = IntVar(0)
660 ShowYCur = IntVar(0)
661 XCursor = YCursor = 0
662 ShowFCur = IntVar(0)
663 ShowdBCur = IntVar(0)
664 FCursor = dBCursor = 0
665 ShowBPCur = IntVar(0)
666 ShowBdBCur = IntVar(0)
667 BPCursor = BdBCursor = 0
668 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
669 PowerStatus = 1
670 TRIGGERsample = 0 # AD sample trigger point
671 DX = 0 # interpolated trigger point
672 
673 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
674 DBdivindex = IntVar(0) # 10 dB/div as initial value
675 DBdivindex.set(4)
676 DBlevel = IntVar(0) # Reference level
677 DBlevel.set(0)
678 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
679 DBdivindexBP.set(4)
680 DBlevelBP = IntVar(0) # Reference level
681 DBlevelBP.set(0)
682 hldn = 0
683 SpectrumScreenStatus = IntVar(0)
684 SmoothCurvesSA = IntVar(0)
685 SmoothCurvesBP = IntVar(0)
686 CutDC = IntVar(0)
687 IAScreenStatus = IntVar(0)
688 NqPScreenStatus = IntVar(0)
689 NqPDisp = IntVar(0)
690 NiCScreenStatus = IntVar(0)
691 NiCDisp = IntVar(0)
692 ImpedanceMagnitude = 0.0 # in ohms
693 ImpedanceAngle = 0.0 # in degrees
694 ImpedanceRseries = 0.0 # in ohms
695 ImpedanceXseries = 0.0 # in ohms
696 Show_Rseries = IntVar(0)
697 Show_Xseries = IntVar(0)
698 Show_Magnitude = IntVar(0)
699 Show_Angle = IntVar(0)
700 Show_RseriesRef = IntVar(0)
701 Show_XseriesRef = IntVar(0)
702 Show_MagnitudeRef = IntVar(0)
703 Show_AngleRef = IntVar(0)
704 
705 TIARline = []
706 TIAXline = []
707 TIAMagline = []
708 TIAAngline = []
709 TIAMline = []
710 TIAMRline = []
711 RefIARline = []
712 RefIAXline = []
713 RefIAMagline = []
714 RefIAAngline = []
715 IASource = IntVar(0)
716 IAGridType = IntVar(0)
717 
718 DisplaySeries = IntVar(0)
719 IA_Ext_Conf = IntVar(0)
720 IASweepSaved = IntVar(0)
721 OverRangeFlagA = 0
722 OverRangeFlagB = 0
723 PeakdbA = 10
724 PeakdbB = 10
725 PeakRelPhase = 0.0
726 PeakfreqA = 100
727 PeakfreqB = 1000
728 OhmStatus = IntVar(0)
729 OhmRunStatus = IntVar(0)
730 FFTbandwidth = 0 # The FFT bandwidth
731 FFTBuffA = [] # Clear the FFTBuff array for trace A
732 FFTBuffB = [] # Clear the FFTBuff array for trace B
733 FFTresultA = [] # FFT result CHA
734 PhaseA = []
735 FFTresultB = [] # FFT result CHB
736 PhaseB = []
737 FFTresultAB = []
738 FFTwindowname = "--" # The FFT window name
739 FFTmemoryA = numpy.ones(1) # The memory for averaging
740 PhaseMemoryA = numpy.ones(1)
741 FFTmemoryB = numpy.ones(1) # The memory for averaging
742 PhaseMemoryB = numpy.ones(1)
743 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
744 SMPfftpwrTwo.set(11)
745 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
746 Two28 = 268435456
747 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
748 
749 T1Fline = [] # Frequency Trace line channel A
750 T2Fline = [] # Frequency Trace line channel B
751 T1Pline = [] # Phase angle Trace line channel A - B
752 T2Pline = [] # Phase angle Trace line channel B - A
753 T1FRline = [] # F reference Trace line channel A
754 T2FRline = [] # F reference Trace line channel B
755 T1PRline = [] # Phase reference Trace line channel A - B
756 T2PRline = [] # Phase reference Trace line channel B - A
757 TFMline = [] # Frequency Math Trace
758 TFRMline = [] # Frequency reference Math Trace
759 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
760 FreqTraceMode.set(1)
761 
762 TAFline = [] # Bode Freq Trace line channel A
763 TBFline = [] # Bode Freq Trace line channel B
764 TAPline = [] # Bode Phase angle Trace line channel A - B
765 TBPline = [] # Bode Phase angle Trace line channel B - A
766 TAFRline = [] # Bode F reference Trace line channel A
767 TBFRline = [] # Bode F reference Trace line channel B
768 TAPRline = [] # Bode Phase reference Trace line channel A - B
769 TBPRline = [] # Bode Phase reference Trace line channel B - A
770 TBPMline = [] # Bode Frequency Math Trace
771 TBPRMline = [] # Bode Frequency reference Math Trace
772 #
773 MinSamplesSA = 64
774 MaxSamplesSA = 65536
775 #
776 MathScreenStatus = IntVar(0)
777 #
778 XYScreenStatus = IntVar(0)
779 Xsignal = IntVar(0) # Signal for X axis variable
780 Xsignal.set(1)
781 YsignalVA = IntVar(0) # Signal for Y axis variable
782 YsignalVB = IntVar(0)
783 YsignalIA = IntVar(0)
784 YsignalIB = IntVar(0)
785 YsignalM = IntVar(0)
786 YsignalMX = IntVar(0)
787 YsignalMY = IntVar(0)
788 YsignalVB.set(1)
789 XYRefAV = IntVar(0) # show reference XY traces
790 XYRefBV = IntVar(0)
791 XYRefAI = IntVar(0)
792 XYRefBI = IntVar(0)
793 XYRefM = IntVar(0)
794 XYRefMX = IntVar(0)
795 XYRefMY = IntVar(0)
796 # show Analog Input Mux Variables
797 Show_CBA = IntVar(0)
798 Show_CBB = IntVar(0)
799 Show_CBC = IntVar(0)
800 Show_CBD = IntVar(0)
801 ShowRMA = IntVar(0)
802 ShowRMB = IntVar(0)
803 ShowRMC = IntVar(0)
804 ShowRMD = IntVar(0)
805 D0 = IntVar(0)
806 D1 = IntVar(0)
807 D2 = IntVar(0)
808 D3 = IntVar(0)
809 D4 = IntVar(0)
810 D5 = IntVar(0)
811 D6 = IntVar(0)
812 D7 = IntVar(0)
813 D0.set(0x50)
814 D1.set(0x50)
815 D2.set(0x50)
816 D3.set(0x50)
817 D4.set(0x50)
818 D5.set(0x50)
819 D6.set(0x50)
820 D7.set(0x50)
821 PIO_0 = 28
822 PIO_1 = 29
823 PIO_2 = 47
824 PIO_3 = 3
825 PIO_4 = 4
826 PIO_5 = 5
827 PIO_6 = 6
828 PIO_7 = 7
829 #
830 SCLKPort = IntVar(0)
831 SDATAPort = IntVar(0)
832 SLATCHPort = IntVar(0)
833 
834 
835 hipulse = """
836 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
837 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
838 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
839 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
840 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
841 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
842 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
843 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
844 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
845 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
846 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
847 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
848 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
849 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
850 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
851 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
852 """
853 hipulseimg = PhotoImage(data=hipulse)
854 
855 lowpulse = """
856 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
857 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
858 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
859 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
860 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
861 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
862 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
863 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
864 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
865 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
866 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
867 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
868 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
869 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
870 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
871 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
872 """
873 lowpulseimg = PhotoImage(data=lowpulse)
874 
875 class CreateToolTip(object):
876 
877  def __init__(self, widget, text='widget info'):
878  self.waittime = 500 #miliseconds
879  self.wraplength = 100 #pixels
880  self.widget = widget
881  self.text = text
882  self.widget.bind("<Enter>", self.enter)
883  self.widget.bind("<Leave>", self.leave)
884  self.widget.bind("<ButtonPress>", self.leave)
885  self.id = None
886  self.tw = None
887 
888  def enter(self, event=None):
889  self.schedule()
890 
891  def leave(self, event=None):
892  self.unschedule()
893  self.hidetip()
894 
895  def schedule(self):
896  self.unschedule()
897  self.id = self.widget.after(self.waittime, self.showtip)
898 
899  def unschedule(self):
900  id = self.id
901  self.id = None
902  if id:
903  self.widget.after_cancel(id)
904 
905  def showtip(self, event=None):
906  x = y = 0
907  x, y, cx, cy = self.widget.bbox("insert")
908  x += self.widget.winfo_rootx() + 25
909  y += self.widget.winfo_rooty() + 20
910  # creates a toplevel window
911  self.tw = Toplevel(self.widget)
912  # Leaves only the label and removes the app window
913  self.tw.wm_overrideredirect(True)
914  self.tw.wm_geometry("+%d+%d" % (x, y))
915  label = Label(self.tw, text=self.text, justify='left',
916  background="#ffffe0", foreground="#000000",
917  relief='solid', borderwidth=1,
918  wraplength = self.wraplength)
919  label.pack(ipadx=1)
920 
921  def hidetip(self):
922  tw = self.tw
923  self.tw= None
924  if tw:
925  tw.destroy()
926 
927  def configure(self, text):
928  self.text = text
929 #
930 # =========== Start widgets routines =============================
931 
933 def BSaveConfig(filename):
934  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
935  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
936  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
937  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
938  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
939  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
940  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
941  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
942  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
943  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
944  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
945  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
946  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
947  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
948  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
949  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
950  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
951  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
952  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
953  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
954  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
955  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
956  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
957  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
958  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
959  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
960  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
961  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb, ChopMuxMode, ChopTrig, DualMuxMode
962  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
963  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
964  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode, ColorMode
965  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
966  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
967  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
968  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
969  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
970  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
971  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
972  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
973  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
974  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
975  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
976  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
977  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
978  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
979  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
980  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
981  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
982  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAcsvFile, AWGBcsvFile
983  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGAwavFile, AWGBwavFile
984  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
985  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
986  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
987  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
988  global phawindow, PhAca, PhAScreenStatus, PhADisp
989  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, BoardStatus, boardwindow, BrdSel
990  global VScale, IScale, RefphEntry, EnableScopeOnly, Roll_Mode
991  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
992  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
993  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
994  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
995  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
996 
997  # open Config file for Write?
998  try:
999  ConfgFile = open(filename, "w")
1000  except: # didn't work? then just return
1001  return
1002  # Save Window placements
1003  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
1004  if EnableScopeOnly == 0:
1005  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
1006  ConfgFile.write('GRW = ' + str(GRW) + '\n')
1007  ConfgFile.write('GRH = ' + str(GRH) + '\n')
1008  ConfgFile.write('ColorMode.set(' + str(ColorMode.get()) + ')\n')
1009  # Windows configuration
1010  ConfgFile.write('MathString = "' + MathString + '"\n')
1011  ConfgFile.write('MathUnits = "' + MathUnits + '"\n')
1012  ConfgFile.write('MathAxis = "' + MathAxis + '"\n')
1013  ConfgFile.write('MathXString = "' + MathXString + '"\n')
1014  ConfgFile.write('MathXUnits = "' + MathXUnits + '"\n')
1015  ConfgFile.write('MathXAxis = "' + MathXAxis + '"\n')
1016  ConfgFile.write('MathYString = "' + MathYString + '"\n')
1017  ConfgFile.write('MathYUnits = "' + MathYUnits + '"\n')
1018  ConfgFile.write('MathYAxis = "' + MathYAxis + '"\n')
1019  if BoardStatus.get() > 0:
1020  ConfgFile.write('MakeBoardScreen()\n')
1021  ConfgFile.write("boardwindow.geometry('+" + str(boardwindow.winfo_x()) + '+' + str(boardwindow.winfo_y()) + "')\n")
1022  ConfgFile.write('BrdSel.set(' + str(BrdSel.get()) + ')\n')
1023  ConfgFile.write('SelectBoard()\n')
1024  else:
1025  ConfgFile.write('DestroyBoardScreen()\n')
1026  if MathScreenStatus.get() > 0:
1027  ConfgFile.write('NewEnterMathControls()\n')
1028  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
1029  else:
1030  ConfgFile.write('DestroyMathScreen()\n')
1031  if XYScreenStatus.get() > 0:
1032  ConfgFile.write('GRWXY = ' + str(GRWXY) + '\n')
1033  ConfgFile.write('GRHXY = ' + str(GRHXY) + '\n')
1034  ConfgFile.write('MakeXYWindow()\n')
1035  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
1036  ConfgFile.write('CHAsbxy.delete(0,END)\n')
1037  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
1038  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
1039  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
1040  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
1041  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
1042  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
1043  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
1044  ConfgFile.write('CHBsbxy.delete(0,END)\n')
1045  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
1046  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
1047  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
1048  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
1049  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
1050  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
1051  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
1052  else:
1053  ConfgFile.write('DestroyXYScreen()\n')
1054  if IAScreenStatus.get() > 0:
1055  ConfgFile.write('GRWIA = ' + str(GRWIA) + '\n')
1056  ConfgFile.write('GRHIA = ' + str(GRHIA) + '\n')
1057  ConfgFile.write('MakeIAWindow()\n')
1058  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
1059  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
1060  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
1061  ConfgFile.write('RsystemEntry.delete(0,END)\n')
1062  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
1063  ConfgFile.write('ResScale.delete(0,END)\n')
1064  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
1065  ConfgFile.write('GainCorEntry.delete(0,END)\n')
1066  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
1067  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
1068  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
1069  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
1070  else:
1071  ConfgFile.write('DestroyIAScreen()\n')
1072  if SpectrumScreenStatus.get() > 0:
1073  ConfgFile.write('GRWF = ' + str(GRWF) + '\n')
1074  ConfgFile.write('GRHF = ' + str(GRHF) + '\n')
1075  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1076  ConfgFile.write('MakeSpectrumWindow()\n')
1077  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
1078  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
1079  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
1080  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
1081  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
1082  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
1083  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
1084  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
1085  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
1086  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
1087  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
1088  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
1089  else:
1090  ConfgFile.write('DestroySpectrumScreen()\n')
1091  #
1092  if DacScreenStatus.get() > 0:
1093  ConfgFile.write('MakeDacScreen()\n')
1094  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
1095  else:
1096  ConfgFile.write('DestroyDacScreen()\n')
1097  if DigScreenStatus.get() > 0:
1098  ConfgFile.write('MakeDigScreen()\n')
1099  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
1100  else:
1101  ConfgFile.write('DestroyDigScreen()\n')
1102  if EnableHSsampling > 0:
1103  ConfgFile.write('FminEntry.delete(0,"end")\n')
1104  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
1105  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
1106  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
1107  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
1108  try:
1109  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
1110  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
1111  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
1112  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
1113  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
1114  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
1115  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
1116  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
1117  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
1118  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
1119  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
1120  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
1121  except:
1122  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
1123  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
1124  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
1125  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
1126  if DigFiltStatus.get() == 1:
1127  ConfgFile.write('MakeDigFiltWindow()\n')
1128  ConfgFile.write("digfltwindow.geometry('+" + str(digfltwindow.winfo_x()) + '+' + str(digfltwindow.winfo_y()) + "')\n")
1129  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
1130  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
1131  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
1132  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
1133  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
1134  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
1135  ConfgFile.write('AWGALenEntry.delete(0,"end")\n')
1136  ConfgFile.write('AWGALenEntry.insert(0, ' + AWGALenEntry.get() + ')\n')
1137  ConfgFile.write('AWGFiltABoxCar.set(' + str(AWGFiltABoxCar.get()) + ')\n')
1138  ConfgFile.write('AWGBLenEntry.delete(0,"end")\n')
1139  ConfgFile.write('AWGBLenEntry.insert(0, ' + AWGBLenEntry.get() + ')\n')
1140  ConfgFile.write('AWGFiltBBoxCar.set(' + str(AWGFiltBBoxCar.get()) + ')\n')
1141  ConfgFile.write('BuildBoxCarA()\n')
1142  ConfgFile.write('BuildBoxCarB()\n')
1143  ConfgFile.write('BuildAWGBoxCarA()\n')
1144  ConfgFile.write('BuildAWGBoxCarB()\n')
1145  else:
1146  ConfgFile.write('DestroyDigFiltScreen()\n')
1147  if MinigenScreenStatus.get() == 1:
1148  ConfgFile.write('MakeMinigenWindow()\n')
1149  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
1150  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
1151  ConfgFile.write('MinigenFout.delete(0,END)\n')
1152  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
1153  ConfgFile.write('MinigenFclk.delete(0,END)\n')
1154  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
1155  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
1156  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
1157  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
1158  else:
1159  ConfgFile.write('DestroyMinigenScreen()\n')
1160  if MuxScreenStatus.get() == 1:
1161  ConfgFile.write('MakeMuxModeWindow()\n')
1162  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
1163  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
1164  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
1165  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
1166  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
1167  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
1168  ConfgFile.write('DualMuxMode.set(' + str(DualMuxMode.get()) + ')\n')
1169  ConfgFile.write('ChopMuxMode.set(' + str(ChopMuxMode.get()) + ')\n')
1170  ConfgFile.write('ChopTrig.set(' + str(ChopTrig.get()) + ')\n')
1171  ConfgFile.write('CHB_Asb.delete(0,END)\n')
1172  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
1173  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
1174  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
1175  ConfgFile.write('CHB_Csb.delete(0,END)\n')
1176  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
1177  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
1178  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
1179  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
1180  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
1181  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
1182  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
1183  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
1184  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
1185  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
1186  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
1187  else:
1188  ConfgFile.write('DestroyMuxScreen()\n')
1189  # Save Phase Anayzer stuff after Analog Mux in case they are both open
1190  if PhAScreenStatus.get() > 0:
1191  ConfgFile.write('GRWPhA = ' + str(GRWPhA) + '\n')
1192  ConfgFile.write('GRHPhA = ' + str(GRHPhA) + '\n')
1193  ConfgFile.write('MakePhAWindow()\n')
1194  ConfgFile.write("phawindow.geometry('+" + str(phawindow.winfo_x()) + '+' + str(phawindow.winfo_y()) + "')\n")
1195  ConfgFile.write('VScale.delete(0,END)\n')
1196  ConfgFile.write('VScale.insert(0, ' + str(VScale.get()) + ')\n')
1197  ConfgFile.write('IScale.delete(0,END)\n')
1198  ConfgFile.write('IScale.insert(0, ' + str(IScale.get()) + ')\n')
1199  ConfgFile.write('RefphEntry.delete(0,END)\n')
1200  ConfgFile.write('RefphEntry.insert(0, "' + str(RefphEntry.get()) + '")\n')
1201  if vat_btn.config('text')[-1] == 'OFF':
1202  ConfgFile.write('vat_btn.config(text="OFF", style="Stop.TButton")\n')
1203  else:
1204  ConfgFile.write('vat_btn.config(text="ON", style="Run.TButton")\n')
1205  if MuxScreenStatus.get() == 0: # these buttons do not exist if Mux screen open
1206  if vbt_btn.config('text')[-1] == 'OFF':
1207  ConfgFile.write('vbt_btn.config(text="OFF", style="Stop.TButton")\n')
1208  else:
1209  ConfgFile.write('vbt_btn.config(text="ON", style="Run.TButton")\n')
1210  if vabt_btn.config('text')[-1] == 'OFF':
1211  ConfgFile.write('vabt_btn.config(text="OFF", style="Stop.TButton")\n')
1212  else:
1213  ConfgFile.write('vabt_btn.config(text="ON", style="Run.TButton")\n')
1214  else: # But these do
1215  ConfgFile.write('ShowPB_A.set(' + str(ShowPB_A.get()) + ')\n')
1216  ConfgFile.write('ShowPB_B.set(' + str(ShowPB_B.get()) + ')\n')
1217  ConfgFile.write('ShowPB_C.set(' + str(ShowPB_C.get()) + ')\n')
1218  ConfgFile.write('ShowPB_D.set(' + str(ShowPB_D.get()) + ')\n')
1219  if iat_btn.config('text')[-1] == 'OFF':
1220  ConfgFile.write('iat_btn.config(text="OFF", style="Stop.TButton")\n')
1221  else:
1222  ConfgFile.write('iat_btn.config(text="ON", style="Run.TButton")\n')
1223  if ibt_btn.config('text')[-1] == 'OFF':
1224  ConfgFile.write('ibt_btn.config(text="OFF", style="Stop.TButton")\n')
1225  else:
1226  ConfgFile.write('ibt_btn.config(text="ON", style="Run.TButton")\n')
1227  #
1228  else:
1229  ConfgFile.write('DestroyPhAScreen()\n')
1230  if BodeScreenStatus.get() == 1:
1231  ConfgFile.write('GRWBP = ' + str(GRWBP) + '\n')
1232  ConfgFile.write('GRHBP = ' + str(GRHBP) + '\n')
1233  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1234  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
1235  ConfgFile.write('MakeBodeWindow()\n')
1236  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
1237  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
1238  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
1239  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
1240  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
1241  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
1242  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
1243  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
1244  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
1245  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
1246  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
1247  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
1248  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
1249  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
1250  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
1251  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
1252  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
1253  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
1254  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
1255  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
1256  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
1257  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
1258  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
1259  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1260  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1261  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1262  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1263  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1264  else:
1265  ConfgFile.write('DestroyBodeScreen()\n')
1266  if MeasureStatus.get() == 1:
1267  # Save strings
1268  ConfgFile.write('ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1269  ConfgFile.write('ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1270  ConfgFile.write('ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1271  ConfgFile.write('ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1272  ConfgFile.write('ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1273  ConfgFile.write('ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1274  ConfgFile.write('ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1275  ConfgFile.write('ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1276  ConfgFile.write('ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1277  ConfgFile.write('ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1278  ConfgFile.write('ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1279  ConfgFile.write('ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1280  ConfgFile.write('ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1281  ConfgFile.write('ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1282  ConfgFile.write('ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1283  ConfgFile.write('ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1284  ConfgFile.write('ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1285  ConfgFile.write('ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1286  ConfgFile.write('ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1287  ConfgFile.write('ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1288  ConfgFile.write('ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1289  ConfgFile.write('ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1290  ConfgFile.write('ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1291  ConfgFile.write('ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1292  ConfgFile.write('MakeMeasureScreen()\n')
1293  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1294  else:
1295  ConfgFile.write('DestroyMeasuewScreen()\n')
1296  if ETSStatus.get() == 1: #
1297  ConfgFile.write('MakeETSWindow()\n')
1298  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1299  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1300  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1301  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1302  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1303  ConfgFile.write('DivXEntry.delete(0,END)\n')
1304  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1305  ConfgFile.write('ETSts.delete(0,END)\n')
1306  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1307  else:
1308  ConfgFile.write('DestroyETSScreen()\n')
1309  #
1310  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1311  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1312  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1313  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1314  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1315  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1316  ConfgFile.write('TMsb.delete(0,END)\n')
1317  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1318  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1319  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1320  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1321  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1322  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1323  ConfgFile.write('Roll_Mode.set(' + str(Roll_Mode.get()) + ')\n')
1324  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1325  ConfgFile.write('YsignalVA.set(' + str(YsignalVA.get()) + ')\n')
1326  ConfgFile.write('YsignalIA.set(' + str(YsignalIA.get()) + ')\n')
1327  ConfgFile.write('YsignalVB.set(' + str(YsignalVB.get()) + ')\n')
1328  ConfgFile.write('YsignalIB.set(' + str(YsignalIB.get()) + ')\n')
1329  ConfgFile.write('YsignalM.set(' + str(YsignalM.get()) + ')\n')
1330  ConfgFile.write('YsignalMX.set(' + str(YsignalMX.get()) + ')\n')
1331  ConfgFile.write('YsignalMY.set(' + str(YsignalMY.get()) + ')\n')
1332  #
1333  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1334  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1335  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1336  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1337  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1338  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1339  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1340  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1341  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1342  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1343  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1344  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1345  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1346  #
1347  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1348  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1349  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1350  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1351  ConfgFile.write('CHAsb.delete(0,END)\n')
1352  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1353  ConfgFile.write('CHAIsb.delete(0,END)\n')
1354  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1355  #
1356  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1357  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1358  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1359  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1360  ConfgFile.write('CHBsb.delete(0,END)\n')
1361  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1362  ConfgFile.write('CHBIsb.delete(0,END)\n')
1363  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1364  # AWG stuff
1365  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1366  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1367  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1368  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1369  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1370  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1371  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1372  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1373  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1374  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1375  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1376  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1377  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1378  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1379  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1380  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1381  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1382  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1383  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1384  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1385  #
1386  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1387  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1388  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1389  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1390  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1391  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1392  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1393  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1394  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1395  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1396  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1397  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1398  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1399  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1400  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1401  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1402  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1403  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1404  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1405  #
1406  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1407  ConfgFile.write('AWGAMathString = "' + AWGAMathString + '"\n')
1408  ConfgFile.write('AWGBMathString = "' + AWGBMathString + '"\n')
1409  ConfgFile.write('AWGAcsvFile = "' + AWGAcsvFile + '"\n')
1410  ConfgFile.write('AWGBcsvFile = "' + AWGBcsvFile + '"\n')
1411  ConfgFile.write('AWGAwavFile = "' + AWGAwavFile + '"\n')
1412  ConfgFile.write('AWGBwavFile = "' + AWGBwavFile + '"\n')
1413  #
1414  if EnableScopeOnly == 0:
1415  ConfgFile.write('AWGANoiseEntry.delete(0,END)\n')
1416  ConfgFile.write('AWGANoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1417  ConfgFile.write('AWGBNoiseEntry.delete(0,END)\n')
1418  ConfgFile.write('AWGBNoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1419  ConfgFile.write('AWGAsbnoise.delete(0,END)\n')
1420  ConfgFile.write('AWGAsbnoise.insert(4, "'+ str(AWGAsbnoise.get()) + '")\n')
1421  ConfgFile.write('AWGBsbnoise.delete(0,END)\n')
1422  ConfgFile.write('AWGBsbnoise.insert(4, "' + str(AWGBsbnoise.get()) + '")\n')
1423  #
1424  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1425  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1426  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1427  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1428  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1429  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1430  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1431  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1432  #
1433  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1434  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1435  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1436  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1437  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1438  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1439  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1440  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1441  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1442  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1443  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1444  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1445  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1446  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1447  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1448  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1449  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1450  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1451  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1452  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1453  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1454  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1455  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1456  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1457  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1458  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1459  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1460  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1461  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1462  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1463  #
1464  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1465  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1466  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1467  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1468  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1469  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1470  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1471  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1472  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1473  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1474  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1475  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1476  #
1477  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1478  #
1479  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1480  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1481  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1482  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1483  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1484  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1485  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1486  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1487  # Save strings
1488  ConfgFile.write('UserAString = "' + UserAString + '"\n')
1489  ConfgFile.write('UserALabel = "' + UserALabel + '"\n')
1490  ConfgFile.write('UserBString = "' + UserBString + '"\n')
1491  ConfgFile.write('UserBLabel = "' + UserBLabel + '"\n')
1492  ConfgFile.write('FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1493  ConfgFile.write('DigFilterAString = "' + DigFilterAString + '"\n')
1494  ConfgFile.write('DigFilterBString = "' + DigFilterBString + '"\n')
1495  # save channel AC frequency compensation settings
1496  try:
1497  CHA_TC1.set(float(cha_TC1Entry.get()))
1498  CHA_TC2.set(float(cha_TC2Entry.get()))
1499  CHB_TC1.set(float(chb_TC1Entry.get()))
1500  CHB_TC2.set(float(chb_TC2Entry.get()))
1501  CHA_A1.set(float(cha_A1Entry.get()))
1502  CHA_A2.set(float(cha_A2Entry.get()))
1503  CHB_A1.set(float(chb_A1Entry.get()))
1504  CHB_A2.set(float(chb_A2Entry.get()))
1505  except:
1506  donothing()
1507  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1508  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1509  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1510  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1511  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1512  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1513  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1514  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1515  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1516  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1517  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1518  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1519  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1520  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1521  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1522  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1523  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1524  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1525  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1526  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1527  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1528  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1529  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1530  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1531  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1532  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1533  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1534  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1535 
1536  # extra Spectrum stuff
1537  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1538  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1539  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1540  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1541  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1542  #
1543  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1544  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1545  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1546  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1547  #
1548  ConfgFile.close()
1549 
1551  global iawindow
1552 
1553  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1554  BSaveConfig(filename)
1555 
1557  global freqwindow
1558 
1559  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1560  BSaveConfig(filename)
1561 
1563  global bodewindow
1564 
1565  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1566  BSaveConfig(filename)
1567 
1569  global root
1570  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1571  BSaveConfig(filename)
1572 
1573 def BLoadConfig(filename):
1574  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1575  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1576  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1577  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1578  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1579  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1580  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1581  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1582  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1583  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1584  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1585  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1586  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1587  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1588  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1589  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1590  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1591  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1592  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1593  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1594  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1595  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1596  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1597  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1598  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1599  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1600  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1601  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1602  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1603  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1604  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1605  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1606  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1607  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1608  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1609  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1610  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1611  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1612  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1613  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1614  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1615  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1616  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1617  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1618  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1619  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1620  global phawindow, PhAca, PhAScreenStatus, PhADisp
1621  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1622  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1623  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
1624  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1625  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1626  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1627  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1628  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1629 
1630  # Read configuration values from file
1631  try:
1632  ConfgFile = open(filename)
1633  for line in ConfgFile:
1634  try:
1635  exec( line.rstrip(), globals(), globals())
1636  #exec( line.rstrip() )
1637  except:
1638  print( "Skipping " + line.rstrip())
1639  ConfgFile.close()
1640  if ScreenWidth < root.winfo_x() or ScreenHeight < root.winfo_y(): # check if main window will be placed off screen?
1641  root.geometry('+0+0')
1642  try:
1643  if ScreenWidth < awgwindow.winfo_x() or ScreenHeight < awgwindow.winfo_y(): # check if AWG window will be placed off screen?
1644  awgwindow.geometry('+0+0')
1645  except:
1646  donothing()
1647  try:
1648  if ScreenWidth < xywindow.winfo_x() or ScreenHeight< xywindow.winfo_y(): # check if XY window will be placed off screen?
1649  xywindow.geometry('+0+0')
1650  except:
1651  donothing()
1652  try:
1653  if ScreenWidth < iawindow.winfo_x() or ScreenHeight < iawindow.winfo_y(): # check if IA window will be placed off screen?
1654  iawindow.geometry('+0+0')
1655  except:
1656  donothing()
1657  try:
1658  if ScreenWidth < freqwindow.winfo_x() or ScreenHeight < freqwindow.winfo_y(): # check if SA window will be placed off screen?
1659  freqwindow.geometry('+0+0')
1660  except:
1661  donothing()
1662  try:
1663  if ScreenWidth < win1.winfo_x() or ScreenHeight < win1.winfo_y(): # check if DAC1 window will be placed off screen?
1664  win1.geometry('+0+0')
1665  except:
1666  donothing()
1667  try:
1668  if ScreenWidth < win2.winfo_x() or ScreenHeight < win2.winfo_y(): # check if DAC2 window will be placed off screen?
1669  win2.geometry('+0+0')
1670  except:
1671  donothing()
1672  try:
1673  if ScreenWidth < minigenwindow.winfo_x() or ScreenHeight < minigenwindow.winfo_y(): # check if mini gen window will be placed off screen?
1674  minigenwindow.geometry('+0+0')
1675  except:
1676  donothing()
1677  try:
1678  if ScreenWidth < muxwindow.winfo_x() or ScreenHeight < muxwindow.winfo_y(): # check if mux window will be placed off screen?
1679  muxwindow.geometry('+0+0')
1680  except:
1681  donothing()
1682  try:
1683  if ScreenWidth < phawindow.winfo_x() or ScreenHeight < phawindow.winfo_y(): # check if PhA window will be placed off screen?
1684  phawindow.geometry('+0+0')
1685  except:
1686  donothing()
1687  try:
1688  if ScreenWidth < bodewindow.winfo_x() or ScreenHeight < bodewindow.winfo_y(): # check if Bode window will be placed off screen?
1689  bodewindow.geometry('+0+0')
1690  except:
1691  donothing()
1692  try:
1693  if ScreenWidth < measurewindow.winfo_x() or ScreenHeight < measurewindow.winfo_y(): # check if Measure window will be placed off screen?
1694  measurewindow.geometry('+0+0')
1695  except:
1696  donothing()
1697  try:
1698  if ScreenWidth < etswindow.winfo_x() or ScreenHeight < etswindow.winfo_y(): # check if ETS window will be placed off screen?
1699  etswindow.geometry('+0+0')
1700  except:
1701  donothing()
1702  if Roll_Mode.get() == 0:
1703  RollBt.config(style="RollOff.TButton",text="Roll-Off")
1704  else:
1705  RollBt.config(style="Roll.TButton",text="Roll-On")
1706  if DevID != "No Device":
1707  BAWGAModeLabel()
1708  BAWGBModeLabel()
1709  BAWGAPhaseDelay()
1710  BAWGBPhaseDelay()
1711  if ColorMode.get() > 0: # White background
1712  # print("White background")
1713  if TRACEwidth.get() < 2:
1714  TRACEwidth.set(2)
1715  COLORtext = "#000000" # 100% black
1716  COLORtrace4 = "#a0a000" # 50% yellow
1717  COLORtraceR4 = "#606000" # 25% yellow
1718  COLORcanvas = "#ffffff" # 100% white
1719  else:
1720  # print("Black background")
1721  COLORcanvas = "#000000" # 100% black
1722  COLORtrace4 = "#ffff00" # 100% yellow
1723  COLORtraceR4 = "#808000" # 50% yellow
1724  COLORtext = "#ffffff" # 100% white
1725  ca.config(background=COLORcanvas)
1726  # Needs to reload from waveform files
1727  if AWGAShape.get()==6:
1728  AWGALoadCSV()
1729  if AWGAShape.get()==13:
1730  AWGALoadWAV()
1731  if AWGBShape.get()==6:
1732  AWGBLoadCSV()
1733  if AWGBShape.get()==13:
1734  AWGBLoadWAV()
1735  # Regenerate waveform from formula
1736  if AWGAShape.get()==10:
1737  AWGAConfigMath()
1738  if AWGBShape.get()==10:
1739  AWGBConfigMath()
1740  if EnableScopeOnly == 0:
1741  UpdateAWGWin()
1742  TimeCheckBox()
1743  XYCheckBox()
1744  FreqCheckBox()
1745  BodeCheckBox()
1746  IACheckBox()
1747  OhmCheckBox()
1748  else:
1749  TimeCheckBox()
1750  XYCheckBox()
1751  UpdateAWGWin()
1752 #
1753  time.sleep(0.05)
1754  ReMakeAWGwaves()
1755  session.end() # Add this to turn off outputs after first time loading a config?
1756  BTime()
1757  except:
1758  print( "Config File Not Found.")
1759 
1760 
1761 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1762  global AWGAShape, AWGBShape, BisCompA, AWGAShapeLabel, AWGBShapeLabel
1763  global AWGALength, AWGBLength, AWGAwaveform, AWGBwaveform, EnableScopeOnly
1764 
1765  if AWGAShape.get()==9:
1766  AWGAMakeImpulse()
1767  AWGAShapeLabel.config(text = "Impulse") # change displayed value
1768  elif AWGAShape.get()==11:
1770  AWGAShapeLabel.config(text = "Trapazoid") # change displayed value
1771  elif AWGAShape.get()==15:
1772  AWGAMakeSSQ()
1773  AWGAShapeLabel.config(text = "SSQ Pulse") # change displayed value
1774  elif AWGAShape.get()==16:
1775  AWGAMakeRamp()
1776  AWGAShapeLabel.config(text = "Ramp") # change displayed value
1777  elif AWGAShape.get()==17:
1778  AWGAMakePWMSine()
1779  AWGAShapeLabel.config(text = "PWN Sine") # change displayed value
1780  elif AWGAShape.get()==18:
1782  AWGAShapeLabel.config(text = "Hi Res Sine") # change displayed value
1783  elif AWGAShape.get()==12:
1785  AWGAShapeLabel.config(text = "Up Down Ramp") # change displayed value
1786  elif AWGAShape.get()==14:
1787  AWGAMakeFourier()
1788  AWGAShapeLabel.config(text = "Fourier Series") # change displayed value
1789  elif AWGAShape.get()==19:
1790  AWGAMakeSinc()
1791  AWGAShapeLabel.config(text = "Sinc Pulse") # change displayed value
1792  elif AWGAShape.get()==20:
1793  AWGAMakePulse()
1794  AWGAShapeLabel.config(text = "Pulse") # change displayed value
1795  elif AWGAShape.get()==21:
1796  AWGAMakeFMSine()
1797  AWGAShapeLabel.config(text = "FM Sine") # change displayed value
1798  elif AWGAShape.get()==22:
1799  AWGAMakeAMSine()
1800  AWGAShapeLabel.config(text = "AM Sine") # change displayed value
1801  elif AWGAShape.get()==7:
1802  AWGAMakeUUNoise()
1803  AWGAShapeLabel.config(text = "UU Noise") # change displayed value
1804  elif AWGAShape.get()==8:
1805  AWGAMakeUGNoise()
1806  AWGAShapeLabel.config(text = "UG Noise") # change displayed value
1807  elif AWGAShape.get()==0:
1808  AWGAShapeLabel.config(text = "DC") # change displayed value
1809  elif AWGAShape.get()==2:
1810  AWGAShapeLabel.config(text = "Triangle") # change displayed value
1811  elif AWGAShape.get()==4:
1812  AWGAShapeLabel.config(text = "Square") # change displayed value
1813  elif AWGAShape.get()==3:
1814  AWGAShapeLabel.config(text = "Saw Tooth") # change displayed value
1815  elif AWGAShape.get()==5:
1816  AWGAShapeLabel.config(text = "Starestep") # change displayed value
1817  elif AWGAShape.get()==6:
1818  AWGAShapeLabel.config(text = "CSV File") # change displayed value
1819  elif AWGAShape.get()==13:
1820  AWGAShapeLabel.config(text = "Wav File") # change displayed value
1821  elif AWGAShape.get()==10:
1822  AWGAShapeLabel.config(text = "Math") # change displayed value
1823  else:
1824  AWGAShapeLabel.config(text = "Other Shape") # change displayed value
1825 #
1826  if BisCompA.get() == 1:
1827  SetBCompA()
1828  if AWGBShape.get()==9:
1829  AWGBMakeImpulse()
1830  AWGBShapeLabel.config(text = "Impulse") # change displayed value
1831  elif AWGBShape.get()==11:
1833  AWGBShapeLabel.config(text = "Trapazoid") # change displayed value
1834  elif AWGBShape.get()==15:
1835  AWGBMakeSSQ()
1836  AWGBShapeLabel.config(text = "SSQ Pulse") # change displayed value
1837  elif AWGBShape.get()==16:
1838  AWGBMakeRamp()
1839  AWGBShapeLabel.config(text = "Ramp") # change displayed value
1840  elif AWGBShape.get()==17:
1841  AWGBMakePWMSine()
1842  AWGBShapeLabel.config(text = "PWN Sine") # change displayed value
1843  elif AWGBShape.get()==18:
1845  AWGBShapeLabel.config(text = "Hi Res Sine") # change displayed value
1846  elif AWGBShape.get()==12:
1848  AWGBShapeLabel.config(text = "Up Down Ramp") # change displayed value
1849  elif AWGBShape.get()==14:
1850  AWGBMakeFourier()
1851  AWGBShapeLabel.config(text = "Fourier Series") # change displayed value
1852  elif AWGBShape.get()==19:
1853  AWGBMakeSinc()
1854  AWGBShapeLabel.config(text = "Sinc Pulse") # change displayed value
1855  elif AWGBShape.get()==20:
1856  AWGBMakePulse()
1857  AWGBShapeLabel.config(text = "Pulse") # change displayed value
1858  elif AWGBShape.get()==7:
1859  AWGBMakeUUNoise()
1860  AWGBShapeLabel.config(text = "UU Noise") # change displayed value
1861  elif AWGBShape.get()==8:
1862  AWGBMakeUGNoise()
1863  AWGBShapeLabel.config(text = "UG Noise") # change displayed value
1864  elif AWGBShape.get()==0:
1865  AWGBShapeLabel.config(text = "DC") # change displayed value
1866  elif AWGBShape.get()==2:
1867  AWGBShapeLabel.config(text = "Triangle") # change displayed value
1868  elif AWGBShape.get()==4:
1869  AWGBShapeLabel.config(text = "Square") # change displayed value
1870  elif AWGBShape.get()==3:
1871  AWGBShapeLabel.config(text = "Saw Tooth") # change displayed value
1872  elif AWGBShape.get()==5:
1873  AWGBShapeLabel.config(text = "Starestep") # change displayed value
1874  elif AWGBShape.get()==6:
1875  AWGBShapeLabel.config(text = "CSV File") # change displayed value
1876  elif AWGBShape.get()==13:
1877  AWGBShapeLabel.config(text = "Wav File") # change displayed value
1878  elif AWGBShape.get()==10:
1879  AWGBShapeLabel.config(text = "Math") # change displayed value
1880  else:
1881  AWGBShapeLabel.config(text = "Other Shape") # change displayed value
1882  if EnableScopeOnly == 0:
1883  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
1884  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
1885  UpdateAwgCont()
1886  time.sleep(0.05)
1887 
1889  global iawindow
1890 
1891  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1892  BLoadConfig(filename)
1893 
1895  global freqwindow
1896 
1897  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1898  BLoadConfig(filename)
1899 
1901  global bodewindow
1902 
1903  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1904  BLoadConfig(filename)
1905 
1907  global root
1908 
1909  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1910  BLoadConfig(filename)
1911  UpdateTimeTrace()
1912 
1914  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
1915  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
1916  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1917  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1918  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1919  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1920  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1921  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1922  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1923  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1924  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1925  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1926  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1927  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1928  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1929  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1930  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1931  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1932  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1933  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1934  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1935  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1936  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1937  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1938  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1939  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1940  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1941  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1942  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1943  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1944  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1945  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1946  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1947  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1948  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1949  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1950  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1951  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1952  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1953  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1954  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1955  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1956  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1957  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1958  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1959  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1960  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1961  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1962  global phawindow, PhAca, PhAScreenStatus, PhADisp
1963  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1964  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1965  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
1966  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1967  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1968  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1969  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1970  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1971  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
1972 
1973  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Script files", "*.txt")], parent=root)
1974  # Read Script commands from file
1975  try:
1976  ConfgFile = open(filename)
1977  for line in ConfgFile:
1978  try:
1979  exec( line.rstrip(), globals(), globals())
1980  # exec( line.rstrip() )
1981  except:
1982  print( "Skipping " + line.rstrip())
1983  showwarning("Syntax Error!",("Syntax Error found in line:\n " + line.rstrip()))
1984  ConfgFile.close()
1985  except:
1986  print( "Config File Not Found.")
1987  showwarning("Warning!","Script File Not Found.")
1988 
1989 
1990 def BgColor():
1991  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus, PhAca, PhAScreenStatus
1992  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
1993  global COLORtrace4, COLORtraceR4, TRACEwidth
1994 
1995  if ColorMode.get() > 0: # White background
1996  if TRACEwidth.get() < 2:
1997  TRACEwidth.set(2)
1998  COLORtext = "#000000" # 100% black
1999  COLORtrace4 = "#a0a000" # 50% yellow
2000  COLORtraceR4 = "#606000" # 25% yellow
2001  COLORcanvas = "#ffffff" # 100% white
2002  else:
2003  COLORcanvas = "#000000" # 100% black
2004  COLORtrace4 = "#ffff00" # 100% yellow
2005  COLORtraceR4 = "#808000" # 50% yellow
2006  COLORtext = "#ffffff" # 100% white
2007  ca.config(background=COLORcanvas)
2009  if SpectrumScreenStatus.get() > 0:
2010  Freqca.config(background=COLORcanvas)
2012  if XYScreenStatus.get() > 0:
2013  XYca.config(background=COLORcanvas)
2014  UpdateXYScreen()
2015  if PhAScreenStatus.get() > 0:
2016  PhAca.config(background=COLORcanvas)
2017  UpdatePhAScreen()
2018  if IAScreenStatus.get() > 0:
2019  IAca.config(background=COLORcanvas)
2020  UpdateIAScreen()
2021  if BodeScreenStatus.get() > 0:
2022  Bodeca.config(background=COLORcanvas)
2024 
2026  global CANVASwidth, CANVASheight
2027  global COLORtext, MarkerNum, ColorMode
2028  # ask for file name
2029  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
2030  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
2031  if MarkerNum > 0 or ColorMode.get() > 0:
2032  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2033  else: # temp chnage text corlor to black
2034  COLORtext = "#000000"
2036  # first save postscript file
2037  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2038  # now convert to bit map
2039  # img = Image.open("screen_shot.eps")
2040  # img.save("screen_shot.gif", "gif")
2041  COLORtext = "#ffffff"
2043 
2045  global CANVASwidthXY, CANVASheightXY, xywindow
2046  global COLORtext, MarkerNum, ColorMode, XYca
2047  # ask for file name
2048  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
2049  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
2050  if MarkerNum > 0 or ColorMode.get() > 0:
2051  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2052  else: # temp chnage text corlor to black
2053  COLORtext = "#000000"
2054  UpdateXYScreen()
2055  # first save postscript file
2056  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2057  # now convert to bit map
2058  # img = Image.open("screen_shot.eps")
2059  # img.save("screen_shot.gif", "gif")
2060  COLORtext = "#ffffff"
2061  UpdateXYScreen()
2062 
2064  global CANVASwidthIA, CANVASheightIA
2065  global COLORtext, IAca, ColorMode, iawindow
2066  # ask for file name
2067  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
2068  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
2069  if ColorMode.get() > 0:
2070  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2071  else: # temp change text color to black for Black BG
2072  COLORtext = "#000000"
2073  UpdateIAScreen()
2074  # save postscript file
2075  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2076  #
2077  COLORtext = "#ffffff"
2078  UpdateIAScreen()
2079 
2081  global CANVASwidthBP, CANVASheightBP
2082  global COLORtext, Bodeca, bodewindow
2083  # ask for file name
2084  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
2085  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
2086  if MarkerNum > 0 or ColorMode.get() > 0:
2087  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2088  else: # temp change text color to black
2089  COLORtext = "#000000"
2091  # save postscript file
2092  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2093  #
2094  COLORtext = "#ffffff"
2096 
2098  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
2099 
2100  # open file to save data
2101  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2102  DataFile = open(filename, 'w')
2103  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
2104  for index in range(len(VBuffA)):
2105  TimePnt = float((index+0.0)/SAMPLErate)
2106  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
2107  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
2108  DataFile.close()
2109 
2111  global SAMPLErate, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2112  # open file to save data
2113  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2114  DataFile = open(filename, 'w')
2115  DataFile.write( 'Sample-#, MuxA, MuxB, MuxC, MuxD \n' )
2116 
2117  for index in range(len(VBuffMA)):
2118  TimePnt = float((index+0.0)/SAMPLErate)
2119  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + ', ' + str(VBuffMB[index]) + ', '
2120  + str(VBuffMC[index]) + ', ' + str(VBuffMD[index]) + '\n')
2121  DataFile.close()
2122 
2123 
2125  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2126 
2127  # ask user for channel to save
2128  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I, CB-I\n MuxA, MuxB, MuxC, MuxD \n Channel:\n", initialvalue="CA-V")
2129  if (Channel == None): # If Cancel pressed, then None
2130  return
2131  # open file to save data
2132  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2133  DataFile = open(filename, 'w')
2134  if Channel == "CA-V":
2135  DataFile.write( 'Sample-#, CA-V\n' )
2136  for index in range(len(VBuffA)):
2137  TimePnt = float((index+0.0)/SAMPLErate)
2138  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
2139  elif Channel == "CA-I":
2140  DataFile.write( 'Sample-#, CA-I,\n' )
2141  for index in range(len(IBuffA)):
2142  TimePnt = float((index+0.0)/SAMPLErate)
2143  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
2144  elif Channel == "CB-V":
2145  DataFile.write( 'Sample-#, CB-V\n' )
2146  for index in range(len(VBuffB)):
2147  TimePnt = float((index+0.0)/SAMPLErate)
2148  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
2149  elif Channel == "CB-I":
2150  DataFile.write( 'Sample-#, CB-I,\n' )
2151  for index in range(len(IBuffB)):
2152  TimePnt = float((index+0.0)/SAMPLErate)
2153  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
2154  elif Channel == "MuxA":
2155  DataFile.write( 'Sample-#, MuxA\n' )
2156  for index in range(len(VBuffMA)):
2157  TimePnt = float((index+0.0)/SAMPLErate)
2158  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + '\n')
2159  elif Channel == "MuxB":
2160  DataFile.write( 'Sample-#, MuxB\n' )
2161  for index in range(len(VBuffMB)):
2162  TimePnt = float((index+0.0)/SAMPLErate)
2163  DataFile.write( str(TimePnt) + ', ' + str(VBuffMB[index]) + '\n')
2164  elif Channel == "MuxC":
2165  DataFile.write( 'Sample-#, MuxC\n' )
2166  for index in range(len(VBuffMC)):
2167  TimePnt = float((index+0.0)/SAMPLErate)
2168  DataFile.write( str(TimePnt) + ', ' + str(VBuffMC[index]) + '\n')
2169  elif Channel == "MuxD":
2170  DataFile.write( 'Sample-#, MuxD\n' )
2171  for index in range(len(VBuffMD)):
2172  TimePnt = float((index+0.0)/SAMPLErate)
2173  DataFile.write( str(TimePnt) + ', ' + str(VBuffMD[index]) + '\n')
2174  DataFile.close()
2175 
2177  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
2178 
2179  # Read values from CVS file
2180  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
2181  try:
2182  CSVFile = open(filename)
2183  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
2184  CSVFile.seek(0)
2185  csv_f = csv.reader(CSVFile, dialect)
2186  VBuffA = []
2187  VBuffB = []
2188  IBuffA = []
2189  IBuffB = []
2190  SHOWsamples = 0
2191  for row in csv_f:
2192  try:
2193  VBuffA.append(float(row[1]))
2194  IBuffA.append(float(row[2]))
2195  VBuffB.append(float(row[3]))
2196  IBuffB.append(float(row[4]))
2197  SHOWsamples = SHOWsamples + 1
2198  except:
2199  print( 'skipping non-numeric row')
2200  VBuffA = numpy.array(VBuffA)
2201  IBuffA = numpy.array(IBuffA)
2202  VBuffB = numpy.array(VBuffB)
2203  IBuffB = numpy.array(IBuffB)
2204  CSVFile.close()
2205  UpdateTimeTrace()
2206  except:
2207  showwarning("WARNING","No such file found or wrong format!")
2208 
2210 def BHelp():
2211 
2212  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
2213  webbrowser.open(url,new=2)
2214 
2215 def BAbout():
2216  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
2217 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
2218  try:
2219  if sys.version_info[0] == 2:
2220  u = urllib2.urlopen(Version_url)
2221  if sys.version_info[0] == 3:
2222  u = urllib.request.urlopen(Version_url)
2223  meta = u.info()
2224  time_string = str(meta.getheaders("Last-Modified"))
2225  except:
2226  time_string = "Unavailable"
2227  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
2228  "Last Released Version: " + time_string[7:18] + "\n" +
2229  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
2230  "Firmware Rev " + str(FWRevOne) + "\n" +
2231  "Board Serial Number " + DevID + "\n" +
2232  "Software is provided as is without any Warranty")
2233 #
2234 
2236  global T1Vline, T2Vline, T1Iline, T2Iline
2237  global Tmathline, TMRline, TXYRline
2238  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
2239  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
2240  global MuxScreenStatus, TMARline, TMBRline, TMCRline, TMDRline
2241  global TMAVline, TMBVline, TMCVline, TMDVline
2242  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
2243  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
2244 
2245  if ShowC1_V.get() == 1:
2246  T1VRline = T1Vline # V reference Trace line channel A
2247  if ShowC2_V.get() == 1:
2248  T2VRline = T2Vline # V reference Trace line channel B
2249  if ShowC1_I.get() == 1:
2250  T1IRline = T1Iline # I reference Trace line channel A
2251  if ShowC2_I.get() == 1:
2252  T2IRline = T2Iline # I reference Trace line channel B
2253  if MathTrace.get() > 0:
2254  TMRline = Tmathline # Math reference Trace line
2255  if MuxScreenStatus.get() > 0:
2256  if Show_CBA.get() > 0:
2257  TMARline = TMAVline # V reference Trace line Mux channel A
2258  if Show_CBB.get() > 0:
2259  TMBRline = TMBVline # V reference Trace line Mux channel B
2260  if Show_CBC.get() > 0:
2261  TMCRline = TMCVline # V reference Trace line Mux channel C
2262  if Show_CBD.get() > 0:
2263  TMDRline = TMDVline # V reference Trace line Mux channel D
2264 #
2265 
2267  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY
2268  global XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
2269 
2270  if len(XYlineVA) > 4:
2271  XYRlineVA = XYlineVA
2272  if len(XYlineVB) > 4:
2273  XYRlineVB = XYlineVB
2274  if len(XYlineIA) > 4:
2275  XYRlineIA = XYlineIA
2276  if len(XYlineIB) > 4:
2277  XYRlineIB = XYlineIB
2278  if len(XYlineM) > 4:
2279  XYRlineM = XYlineM
2280  if len(XYlineMX) > 4:
2281  XYRlineMX = XYlineMX
2282  if len(XYlineMY) > 4:
2283  XYRlineMY = XYlineMY
2284 #
2285 
2286 def BSaveCal():
2287  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2288  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2289  global DevID
2290  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2291  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2292  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2293  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2294 
2295  devidstr = DevID[17:31]
2296  filename = devidstr + "_O.cal"
2297  CalFile = open(filename, "w")
2298  #
2299  CalFile.write('CHAVGainEntry.delete(0,END)\n')
2300  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
2301  CalFile.write('CHBVGainEntry.delete(0,END)\n')
2302  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
2303  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
2304  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
2305  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
2306  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
2307  #
2308  CalFile.write('CHAIGainEntry.delete(0,END)\n')
2309  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
2310  CalFile.write('CHBIGainEntry.delete(0,END)\n')
2311  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
2312  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
2313  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
2314  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
2315  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
2316  #
2317  # save channel AC frequency compensation settings
2318  try:
2319  CHA_TC1.set(float(cha_TC1Entry.get()))
2320  CHA_TC2.set(float(cha_TC2Entry.get()))
2321  CHB_TC1.set(float(chb_TC1Entry.get()))
2322  CHB_TC2.set(float(chb_TC2Entry.get()))
2323  CHA_A1.set(float(cha_A1Entry.get()))
2324  CHA_A2.set(float(cha_A2Entry.get()))
2325  CHB_A1.set(float(chb_A1Entry.get()))
2326  CHB_A2.set(float(chb_A2Entry.get()))
2327  except:
2328  donothing()
2329  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
2330  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
2331  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
2332  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
2333  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
2334  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
2335  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
2336  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
2337  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
2338  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
2339  CalFile.write('cha_TC1Entry.delete(0,END)\n')
2340  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
2341  CalFile.write('cha_TC2Entry.delete(0,END)\n')
2342  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
2343  CalFile.write('chb_TC1Entry.delete(0,END)\n')
2344  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
2345  CalFile.write('chb_TC2Entry.delete(0,END)\n')
2346  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
2347  CalFile.write('cha_A1Entry.delete(0,END)\n')
2348  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
2349  CalFile.write('cha_A2Entry.delete(0,END)\n')
2350  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
2351  CalFile.write('chb_A1Entry.delete(0,END)\n')
2352  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
2353  CalFile.write('chb_A2Entry.delete(0,END)\n')
2354  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
2355 
2356  CalFile.close()
2357 
2358 def BLoadCal():
2359  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2360  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2361  global DevID
2362  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2363  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2364  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2365  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2366 
2367  devidstr = DevID[17:31]
2368  filename = devidstr + "_O.cal"
2369  try:
2370  CalFile = open(filename)
2371  for line in CalFile:
2372  exec( line.rstrip() )
2373  CalFile.close()
2374  except:
2375  print( "Cal file for this device not found")
2376 
2378  global UserAString, UserALabel, MeasUserA
2379 
2380  TempString = UserALabel
2381  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
2382  if (UserALabel == None): # If Cancel pressed, then None
2383  MeasUserA.set(0)
2384  UserALabel = TempString
2385  return
2386  TempString = UserAString
2387  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
2388  if (UserAString == None): # If Cancel pressed, then None
2389  MeasUserA.set(0)
2390  UserAString = TempString
2391  return
2392  MeasUserA.set(1)
2393 
2395  global UserBString, UserBLabel, MeasUserB
2396 
2397  TempString = UserBLabel
2398  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
2399  if (UserBLabel == None): # If Cancel pressed, then None
2400  MeasUserB.set(0)
2401  UserBLabel = TempString
2402  return
2403  TempString = UserBString
2404  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
2405  if (UserBString == None): # If Cancel pressed, then None
2406  MeasUserB.set(0)
2407  UserBString = TempString
2408  return
2409  MeasUserB.set(1)
2410 #
2411 
2413  global LabelPlotText, PlotLabelText # = "Custom Plot Label"
2414 
2415  TempString = PlotLabelText
2416  PlotLabelText = askstring("Custom Label", "Current Plot Label: " + PlotLabelText + "\n\nNew Label:\n", initialvalue=PlotLabelText)
2417  if (PlotLabelText == None): # If Cancel pressed, then None
2418  LabelPlotText.set(0)
2419  PlotLabelText = TempString
2420  return
2421  LabelPlotText.set(1)
2422 
2424  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
2425  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
2426  global MathAxis, MathXAxis, MathYAxis, MathTrace
2427  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
2428  global formlab, xformlab, yformlab, FrameBG
2429  global Mframe1, Mframe2, Mframe3, Mframe4
2430 
2431  if MathScreenStatus.get() == 0:
2432  MathScreenStatus.set(1)
2433  #
2434  MathWindow = Toplevel()
2435  MathWindow.title("Math Formula " + SWRev + RevDate)
2436  MathWindow.resizable(FALSE,FALSE)
2437  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
2438  MathWindow.configure(background=FrameBG)
2439  Mframe1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10T5.TLabelframe") #"A10T5.TLabelframe")
2440  Mframe2 = LabelFrame(MathWindow, text="Math Trace", style="A10T5.TLabelframe")
2441  Mframe3 = LabelFrame(MathWindow, text="X Math Trace", style="A10T6.TLabelframe")
2442  Mframe4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10T7.TLabelframe")
2443  # frame1.grid(row=0, column=0, sticky=W)
2444  #
2445  Mframe1.grid(row = 0, column=0, rowspan=3, sticky=W)
2446  Mframe2.grid(row = 0, column=1, sticky=W)
2447  Mframe3.grid(row = 1, column=1, sticky=W)
2448  Mframe4.grid(row = 2, column=1, sticky=W)
2449  #
2450  # Built in functions
2451  #
2452  mrb1 = Radiobutton(Mframe1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
2453  mrb1.grid(row=0, column=0, sticky=W)
2454  mrb2 = Radiobutton(Mframe1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
2455  mrb2.grid(row=1, column=0, sticky=W)
2456  mrb3 = Radiobutton(Mframe1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
2457  mrb3.grid(row=2, column=0, sticky=W)
2458  mrb4 = Radiobutton(Mframe1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
2459  mrb4.grid(row=3, column=0, sticky=W)
2460  mrb5 = Radiobutton(Mframe1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
2461  mrb5.grid(row=4, column=0, sticky=W)
2462  mrb6 = Radiobutton(Mframe1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
2463  mrb6.grid(row=5, column=0, sticky=W)
2464  mrb7 = Radiobutton(Mframe1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
2465  mrb7.grid(row=6, column=0, sticky=W)
2466  mrb8 = Radiobutton(Mframe1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
2467  mrb8.grid(row=7, column=0, sticky=W)
2468  mrb9 = Radiobutton(Mframe1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
2469  mrb9.grid(row=8, column=0, sticky=W)
2470  mrb10 = Radiobutton(Mframe1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
2471  mrb10.grid(row=9, column=0, sticky=W)
2472  mrb11 = Radiobutton(Mframe1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
2473  mrb11.grid(row=10, column=0, sticky=W)
2474  mrb12 = Radiobutton(Mframe1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
2475  mrb12.grid(row=11, column=0, sticky=W)
2476  mrb13 = Radiobutton(Mframe1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
2477  mrb13.grid(row=12, column=0, sticky=W)
2478  #
2479  # Math trace formula sub Mframe2
2480  #
2481  sframe2a = Frame( Mframe2 )
2482  sframe2a.pack(side=TOP)
2483  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
2484  formlab.pack(side=LEFT)
2485  formentry = Entry(sframe2a, width=23)
2486  formentry.pack(side=LEFT)
2487  formentry.delete(0,"end")
2488  formentry.insert(0,MathString)
2489  sframe2b = Frame( Mframe2 )
2490  sframe2b.pack(side=TOP)
2491  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
2492  unitslab.pack(side=LEFT)
2493  unitsentry = Entry(sframe2b, width=6)
2494  unitsentry.pack(side=LEFT)
2495  unitsentry.delete(0,"end")
2496  unitsentry.insert(0,MathUnits)
2497  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
2498  checkbt.pack(side=LEFT)
2499  sframe2c = Frame( Mframe2 )
2500  sframe2c.pack(side=TOP)
2501  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
2502  axislab.pack(side=LEFT)
2503  axisentry = Entry(sframe2c, width=4)
2504  axisentry.pack(side=LEFT)
2505  axisentry.delete(0,"end")
2506  axisentry.insert(0,MathAxis)
2507  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
2508  applybt.pack(side=LEFT)
2509  #
2510  # X Math trace formula sub Mframe3
2511  #
2512  sframe3a = Frame( Mframe3 )
2513  sframe3a.pack(side=TOP)
2514  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
2515  xformlab.pack(side=LEFT)
2516  xformentry = Entry(sframe3a, width=23)
2517  xformentry.pack(side=LEFT)
2518  xformentry.delete(0,"end")
2519  xformentry.insert(0, MathXString)
2520  sframe3b = Frame( Mframe3 )
2521  sframe3b.pack(side=TOP)
2522  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
2523  xunitslab.pack(side=LEFT)
2524  xunitsentry = Entry(sframe3b, width=6)
2525  xunitsentry.pack(side=LEFT)
2526  xunitsentry.delete(0,"end")
2527  xunitsentry.insert(0, MathXUnits)
2528  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
2529  xcheckbt.pack(side=LEFT)
2530  sframe3c = Frame( Mframe3 )
2531  sframe3c.pack(side=TOP)
2532  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
2533  xaxislab.pack(side=LEFT)
2534  xaxisentry = Entry(sframe3c, width=4)
2535  xaxisentry.pack(side=LEFT)
2536  xaxisentry.delete(0,"end")
2537  xaxisentry.insert(0, MathXAxis)
2538  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
2539  xapplybt.pack(side=LEFT)
2540  #
2541  # Math trace formula sub Mframe4
2542  #
2543  sframe4a = Frame( Mframe4 )
2544  sframe4a.pack(side=TOP)
2545  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
2546  yformlab.pack(side=LEFT)
2547  yformentry = Entry(sframe4a, width=23)
2548  yformentry.pack(side=LEFT)
2549  yformentry.delete(0,"end")
2550  yformentry.insert(0,MathYString)
2551  sframe4b = Frame( Mframe4 )
2552  sframe4b.pack(side=TOP)
2553  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
2554  yunitslab.pack(side=LEFT)
2555  yunitsentry = Entry(sframe4b, width=6)
2556  yunitsentry.pack(side=LEFT)
2557  yunitsentry.delete(0,"end")
2558  yunitsentry.insert(0,MathYUnits)
2559  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
2560  ycheckbt.pack(side=LEFT)
2561  sframe4c = Frame( Mframe4 )
2562  sframe4c.pack(side=TOP)
2563  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
2564  yaxislab.pack(side=LEFT)
2565  yaxisentry = Entry(sframe4c, width=4)
2566  yaxisentry.pack(side=LEFT)
2567  yaxisentry.delete(0,"end")
2568  yaxisentry.insert(0,MathYAxis)
2569  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
2570  yapplybt.pack(side=LEFT)
2571 
2572  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
2573  dismissbutton.grid(row=3, column=0, sticky=W)
2574 
2575  if RUNstatus.get() > 0:
2576  UpdateTimeTrace()
2577 
2579  global MathScreenStatus, MathWindow
2580 
2581  if MathScreenStatus.get() == 1:
2582  MathScreenStatus.set(0)
2583  MathWindow.destroy()
2584 
2586  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
2587  global VBuffA, VBuffB, IBuffA, IBuffB
2588  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2589  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2590  global FFTBuffA, FFTBuffB, FFTwindowshape
2591  global AWGAwaveform, AWGBwaveform
2592  global Show_MathX, Show_MathY
2593  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2594  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2595 
2596  t = 0
2597  TempString = formentry.get()
2598  try:
2599  MathResult = eval(TempString)
2600  formlab.configure(text="Formula ", style= "A10G.TLabel")
2601  except:
2602  formlab.configure(text="Formula ", style= "A10R.TLabel")
2603 
2605  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
2606  global VBuffA, VBuffB, IBuffA, IBuffB
2607  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2608  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2609  global FFTBuffA, FFTBuffB, FFTwindowshape
2610  global AWGAwaveform, AWGBwaveform
2611  global Show_MathX, Show_MathY
2612  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2613  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2614 
2615  t = 0
2616  TempString = xformentry.get()
2617  try:
2618  MathResult = eval(TempString)
2619  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
2620  except:
2621  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
2622 
2624  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
2625  global VBuffA, VBuffB, IBuffA, IBuffB
2626  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2627  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2628  global FFTBuffA, FFTBuffB, FFTwindowshape
2629  global AWGAwaveform, AWGBwaveform
2630  global Show_MathX, Show_MathY
2631  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2632  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2633 
2634  t = 0
2635  TempString = yformentry.get()
2636  try:
2637  MathResult = eval(TempString)
2638  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
2639  except:
2640  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
2641 
2643  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
2644 
2645  MathString = formentry.get()
2646  MathUnits = unitsentry.get()
2647  MathAxis = axisentry.get()
2648 
2650  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
2651 
2652  MathXString = xformentry.get()
2653  MathXUnits = xunitsentry.get()
2654  MathXAxis = xaxisentry.get()
2655 
2657  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
2658 
2659  MathYString = yformentry.get()
2660  MathYUnits = yunitsentry.get()
2661  MathYAxis = yaxisentry.get()
2662 
2664  global MarkerLoc, RUNstatus
2665 
2666  TempString = MarkerLoc
2667  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
2668  if (MarkerLoc == None): # If Cancel pressed, then None
2669  MarkerLoc = TempString
2670  if RUNstatus.get() == 0: # if not running
2671  UpdateTimeTrace() # Update
2672 
2674  global RUNstatus
2675 
2676 def DoNothing(event):
2677  global RUNstatus
2678 
2680  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
2681 
2682  ShowC1_V.set(1)
2683  ShowC1_I.set(1)
2684  ShowC2_V.set(1)
2685  ShowC2_I.set(1)
2686  if RUNstatus.get() == 0: # if not running
2687  UpdateTimeTrace() # Update
2688 
2690  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
2691 
2692  ShowC1_V.set(0)
2693  ShowC1_I.set(0)
2694  ShowC2_V.set(0)
2695  ShowC2_I.set(0)
2696  if RUNstatus.get() == 0: # if not running
2697  UpdateTimeTrace() # Update
2698 
2700  global TgEdge
2701 
2702 # TRIGCOND trigcondRisingPositive = 0
2703 # TRIGCOND trigcondFallingNegative = 1
2704 
2706  global TgInput, TRIGGERlevel, TRIGGERentry, RUNstatus
2707  global MaxV1, MinV1, MaxV2, MinV2
2708  global MaxI1, MinI1, MaxI2, MinI2
2709  global MidVMuxA, MidVMuxB, MidVMuxC, MidVMuxD
2710  global ChopMuxMode, ChopTrig
2711  # set new trigger level to mid point of waveform
2712  MidV1 = (MaxV1+MinV1)/2
2713  MidV2 = (MaxV2+MinV2)/2
2714  MidI1 = (MaxI1+MinI1)/2
2715  MidI2 = (MaxI2+MinI2)/2
2716  if (TgInput.get() == 0):
2717  DCString = "0.0"
2718  elif (TgInput.get() == 1 or TgInput.get() == 5):
2719  DCString = ' {0:.2f} '.format(MidV1)
2720  elif (TgInput.get() == 2 ):
2721  DCString = ' {0:.2f} '.format(MidI1)
2722  elif (TgInput.get() == 3 ):
2723  DCString = ' {0:.2f} '.format(MidV2)
2724  elif (TgInput.get() == 4 ):
2725  DCString = ' {0:.2f} '.format(MidI2)
2726 #
2727  if ChopMuxMode.get() > 0:
2728  if ChopTrig.get() == 0:
2729  DCString = "0.0"
2730  if ChopTrig.get() == 1:
2731  DCString = ' {0:.2f} '.format(MidVMuxA)
2732  if ChopTrig.get() == 2:
2733  DCString = ' {0:.2f} '.format(MidVMuxB)
2734  if ChopTrig.get() == 3:
2735  DCString = ' {0:.2f} '.format(MidVMuxC)
2736  if ChopTrig.get() == 4:
2737  DCString = ' {0:.2f} '.format(MidVMuxD)
2738 #
2739  TRIGGERlevel = eval(DCString)
2740  TRIGGERentry.delete(0,END)
2741  TRIGGERentry.insert(4, DCString)
2742  if RUNstatus.get() == 0: # if not running
2743  UpdateTimeTrace() # Update
2744 
2745 
2747  global TgInput
2748 
2749 # if (TgInput.get() == 0):
2750  # no trigger
2751 # elif (TgInput.get() == 1):
2752  # trigger source set to detector of analog in channels
2753  # auto trigger timeout value
2754 # elif (TgInput.get() == 2):
2755  # trigger source set to detector of analog in channels
2756  # 0 disables auto trigger
2757 
2758 def BTriglevel(event):
2759  global TRIGGERlevel, TRIGGERentry, RUNstatus
2760 
2761  # evalute entry string to a numerical value
2762  try:
2763  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2764  except:
2765  TRIGGERentry.delete(0,END)
2766  TRIGGERentry.insert(0, TRIGGERlevel)
2767  # set new trigger level
2768  if RUNstatus.get() == 0: # if not running
2769  UpdateTimeTrace() # Update
2770 
2771 
2772 def BHoldOff(event):
2773  global HoldOff, HoldOffentry, RUNstatus
2774 
2775  try:
2776  HoldOff = float(eval(HoldOffentry.get()))
2777  except:
2778  HoldOffentry.delete(0,END)
2779  HoldOffentry.insert(0, HoldOff)
2780  if RUNstatus.get() == 0: # if not running
2781  UpdateTimeTrace() # Update
2782 # Set Horx possition from entry widget
2783 def BHozPoss(event):
2784  global HozPoss, HozPossentry, RUNstatus
2785 
2786  try:
2787  HozPoss = float(eval(HozPossentry.get()))
2788  except:
2789  HozPossentry.delete(0,END)
2790  HozPossentry.insert(0, HozPoss)
2791  if RUNstatus.get() == 0: # if not running
2792  UpdateTimeTrace() # Update
2793 #
2795  global HozPossentry, TgInput, TMsb
2796 
2797  # get time scale
2798  try:
2799  TIMEdiv = float(eval(TMsb.get()))
2800  except:
2801  TIMEdiv = 0.5
2802  TMsb.delete(0,"end")
2803  TMsb.insert(0,TIMEdiv)
2804  # prevent divide by zero error
2805  if TIMEdiv < 0.0002:
2806  TIMEdiv = 0.01
2807  if TgInput.get() > 0:
2808  HozPoss = -5 * TIMEdiv
2809  HozPossentry.delete(0,END)
2810  HozPossentry.insert(0, HozPoss)
2811 #
2813  global HoldOffentry, HoldOff, TgInput, TMsb
2814 
2815 # get time scale
2816  try:
2817  TIMEdiv = float(eval(TMsb.get()))
2818  except:
2819  TIMEdiv = 0.5
2820  TMsb.delete(0,"end")
2821  TMsb.insert(0,TIMEdiv)
2822  # prevent divide by zero error
2823  if TIMEdiv < 0.0002:
2824  TIMEdiv = 0.01
2825  if TgInput.get() == 0:
2826  HoldOff = HoldOff + TIMEdiv
2827  HoldOffentry.delete(0,END)
2828  HoldOffentry.insert(0, HoldOff)
2829 
2831  global CHB_APosEntry, DCVMuxA
2832 
2833  CHB_APosEntry.delete(0,"end")
2834  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2835 #
2837  global CHB_BPosEntry, DCVMuxB
2838 
2839  CHB_BPosEntry.delete(0,"end")
2840  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2841 #
2843  global CHB_CPosEntry, DCVMuxC
2844 
2845  CHB_CPosEntry.delete(0,"end")
2846  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2847 #
2849  global CHD_BPosEntry, DCVMuxD
2850 
2851  CHB_DPosEntry.delete(0,"end")
2852  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2853 #
2855  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2856 
2857  if MarkerScale.get() != 1:
2858  MarkerScale.set(5)
2859  CHB_Alab.config(style="Rtrace2.TButton")
2860  CHB_Blab.config(style="Strace6.TButton")
2861  CHB_Clab.config(style="Strace7.TButton")
2862  CHB_Dlab.config(style="Strace4.TButton")
2863  else:
2864  MarkerScale.set(0)
2865 #
2867  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2868 
2869  if MarkerScale.get() != 1:
2870  MarkerScale.set(6)
2871  CHB_Alab.config(style="Strace2.TButton")
2872  CHB_Blab.config(style="Rtrace6.TButton")
2873  CHB_Clab.config(style="Strace7.TButton")
2874  CHB_Dlab.config(style="Strace4.TButton")
2875  else:
2876  MarkerScale.set(0)
2877 #
2879  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2880 
2881  if MarkerScale.get() != 1:
2882  MarkerScale.set(7)
2883  CHB_Alab.config(style="Strace2.TButton")
2884  CHB_Blab.config(style="Strace6.TButton")
2885  CHB_Clab.config(style="Rtrace7.TButton")
2886  CHB_Dlab.config(style="Strace4.TButton")
2887  else:
2888  MarkerScale.set(0)
2889 #
2891  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2892 
2893  if MarkerScale.get() != 1:
2894  MarkerScale.set(8)
2895  CHB_Alab.config(style="Strace2.TButton")
2896  CHB_Blab.config(style="Strace6.TButton")
2897  CHB_Clab.config(style="Strace7.TButton")
2898  CHB_Dlab.config(style="Rtrace4.TButton")
2899  else:
2900  MarkerScale.set(0)
2901 #
2903  global CHAVPosEntry, DCV1
2904 
2905  CHAVPosEntry.delete(0,"end")
2906  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2907 #
2909  global CHBVPosEntry, DCV2
2910 
2911  CHBVPosEntry.delete(0,"end")
2912  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2913 #
2915  global CHAIPosEntry, DCI1
2916 
2917  CHAIPosEntry.delete(0,"end")
2918  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2919 #
2921  global CHBIPosEntry, DCI2
2922 
2923  CHBIPosEntry.delete(0,"end")
2924  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2925 #
2927  global CHAVPosEntryxy, DCV1
2928 
2929  CHAVPosEntryxy.delete(0,"end")
2930  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2931 #
2933  global CHBVPosEntryxy, DCV2
2934 
2935  CHBVPosEntryxy.delete(0,"end")
2936  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2937 #
2939  global CHAIPosEntryxy, DCI1
2940 
2941  CHAIPosEntryxy.delete(0,"end")
2942  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2943 #
2945  global CHBIPosEntryxy, DCI2
2946 
2947  CHBIPosEntryxy.delete(0,"end")
2948  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
2949 
2951  global RUNstatus, session, CHA, CHB, devx, AWG_2X, Closed
2952 
2953  RUNstatus.set(0)
2954  Closed = 1
2955  # BSaveConfig("alice-last-config.cfg")
2956  try:
2957  # try to write last config file, Don't crash if running in Write protected space
2958  BSaveConfig("alice-last-config.cfg")
2959  # Put channels in Hi-Z and exit
2960  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2961  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2962  devx.set_adc_mux(0) # set ADC mux conf to default
2963  AWG_2X.set(0)
2964  BAWG2X()
2965  CHA.constant(0.0)
2966  CHB.constant(0.0)
2967  devx.set_led(0b001) # Set LED.red on the way out
2968  if session.continuous:
2969  session.end()
2970  except:
2971  donothing()
2972 
2973  root.destroy()
2974  exit()
2975 
2976 def BStart():
2977  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
2978  global contloop, discontloop, TIMEdiv, First_Slow_sweep
2979  global TimeDisp, XYDisp, PhADisp, FreqDisp, BodeDisp, IADisp
2980 
2981  if DevID == "No Device":
2982  showwarning("WARNING","No Device Plugged In!")
2983  elif FWRevOne == 0.0:
2984  showwarning("WARNING","Out of data Firmware!")
2985  elif TimeDisp.get() == 0 and XYDisp.get() == 0 and PhADisp.get() == 0 and FreqDisp.get() == 0 and BodeDisp.get() == 0 and IADisp.get() == 0:
2986  showwarning("WARNING","Enable at least one Instrument!")
2987  else:
2988  if PowerStatus == 0:
2989  PowerStatus = 1
2990  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2991  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2992  if (RUNstatus.get() == 0):
2993  RUNstatus.set(1)
2994  if AWGSync.get() == 0:
2995  session.flush()
2996  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2997  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2998  BAWGEnab()
2999  if not session.continuous:
3000  session.start(0)
3001  time.sleep(0.02) # wait awhile here for some reason
3002  elif session.continuous:
3003  session.end()
3004  session.flush()
3005  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3006  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3007 
3019  BAWGEnab()
3020  else:
3021  contloop = 0
3022  discontloop = 1
3023  if session.continuous:
3024  session.end() # end continuous session mode
3025 
3026  # UpdateTimeScreen() # Always Update
3027  if TIMEdiv >= 100:
3028  First_Slow_sweep = 0
3029  else:
3030  First_Slow_sweep = 1
3031 #$ Start running Ohmmeter tool
3033  global session, AWGSync
3034 
3035  AWGSync.set(1)
3036  if AWGSync.get() == 0:
3037  session.flush()
3038  if not session.continuous:
3039  session.start(0)
3040  time.sleep(0.02) # wait awhile here for some reason
3041  elif session.continuous:
3042  session.end()
3043  session.flush()
3044  else:
3045  contloop = 0
3046  discontloop = 1
3047  if session.continuous:
3048  session.end() # end continuous session mode
3049 
3050 def BStartIA():
3051  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne, NetworkScreenStatus
3052 
3053  try:
3054  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
3055  except:
3056  AWGAFreqEntry.delete(0,"end")
3057  AWGAFreqEntry.insert(0, AWGAFreqvalue)
3058  if FWRevOne > 2.16:
3059  if AWGAFreqvalue > 10000.0:
3060  Two_X_Sample.set(1)
3061  else:
3062  Two_X_Sample.set(0)
3063  SetADC_Mux()
3064  IASourceSet()
3065  if NetworkScreenStatus.get() > 0:
3066  BStartBP()
3067  else:
3068  BStart()
3069 
3071  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode, AWGSync
3072 
3073  if AWGSync.get() == 0: # running in continuous mode
3074  AWGSync.set(1)
3075  if IASource.get() == 1:
3076  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
3077  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3078  AWGAMode.set(2) # Set AWG A to Hi-Z
3079  else:
3080  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
3081  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3082  AWGAMode.set(0) # Set AWG A to SVMI
3083  if AWGBIOMode.get() == 0: # if not in split I/O mode
3084  AWGBMode.set(2) # Set AWG B to Hi-Z
3085 
3086 def BStop():
3087  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
3088  global CHA, CHB, contloop, discontloop
3089 
3090  if (RUNstatus.get() == 1):
3091  # print("Stoping")
3092  RUNstatus.set(0)
3093  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3094  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3095  if AWGSync.get() == 0: # running in continuous mode
3096  CHA.constant(0.0)
3097  CHB.constant(0.0)
3098  # print("Stoping continuous mode")
3099  # session.cancel() # cancel continuous session mode while paused
3100  if session.continuous:
3101  #print( "Is Continuous? ", session.continuous)
3102  session.end()
3103  #time.sleep(0.02)
3104  #print( "Is Continuous? ", session.continuous)
3105  else:
3106  contloop = 0
3107  discontloop = 1
3108  session.cancel()
3109 #
3110  if TimeDisp.get() > 0:
3111  UpdateTimeScreen() # Always Update screens as necessary
3112  if XYDisp.get() > 0:
3113  UpdateXYScreen()
3114  if FreqDisp.get() > 0:
3116  if IADisp.get() > 0:
3117  UpdateIAScreen()
3118 
3119 def BPower():
3120  global RUNstatus, PowerStatus, devx, PwrBt
3121 
3122  if (RUNstatus.get() == 1):
3123  BStop()
3124  if PowerStatus == 1:
3125  PowerStatus = 0
3126  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
3127  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
3128  else:
3129  PowerStatus = 1
3130  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3131  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3132 
3133 def BRoll():
3134  global Roll_Mode, RollBt
3135 
3136  if Roll_Mode.get() == 1:
3137  Roll_Mode.set(0)
3138  RollBt.config(style="RollOff.TButton",text="Roll-Off")
3139  else:
3140  Roll_Mode.set(1)
3141  RollBt.config(style="Roll.TButton",text="Roll-On")
3142 
3143 
3144 def BTime():
3145  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne, ChopMuxMode
3146  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, AWGSync
3147 
3148  try: # get time scale in mSec/div
3149  TIMEdiv = float(eval(TMsb.get()))
3150  if TIMEdiv < 0.0002:
3151  TIMEdiv = 0.01
3152  TMsb.delete(0,"end")
3153  TMsb.insert(0,TIMEdiv)
3154  except:
3155  TIMEdiv = 0.5
3156  TMsb.delete(0,"end")
3157  TMsb.insert(0,TIMEdiv)
3158  # Switch to 2X sampleling if time scale small enough and not runing ETS
3159  # and not in analog input mux Chop mode.
3160  if ETSDisp.get() == 0 and ChopMuxMode.get() == 0:
3161  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
3162  if FWRevOne > 2.16:
3163  if Samples_per_div < 20.0:
3164  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
3165  if NumTraces > 2 and AWGSync.get() == 0:
3166  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
3167  BStop()
3168  Two_X_Sample.set(1)
3170  else:
3171  Two_X_Sample.set(0)
3172  SetADC_Mux()
3173  #
3174  if RUNstatus.get() == 0: # if not running
3175  UpdateTimeTrace() # Update
3176 
3178  global CHAsb, RUNstatus, CH1vpdvLevel
3179 
3180  try:
3181  CH1vpdvLevel = float(eval(CHAsb.get()))
3182  except:
3183  CHAsb.delete(0,END)
3184  CHAsb.insert(0, CH1vpdvLevel)
3185  if RUNstatus.get() == 0:
3186  UpdateTimeTrace() # if not running Update
3187 
3189  global CHAIsb, RUNstatus, CH1ipdvLevel
3190 
3191  try:
3192  CH1ipdvLevel = float(eval(CHAIsb.get()))
3193  except:
3194  CHAIsb.delete(0,END)
3195  CHAIsb.insert(0, CH1ipdvLevel)
3196  if RUNstatus.get() == 0:
3197  UpdateTimeTrace() # if not running Update
3198 
3200  global CHBsb, RUNstatus, CH2vpdvLevel
3201 
3202  try:
3203  CH2vpdvLevel = float(eval(CHBsb.get()))
3204  except:
3205  CHBsb.delete(0,END)
3206  CHBsb.insert(0, CH2vpdvLevel)
3207  if RUNstatus.get() == 0:
3208  UpdateTimeTrace() # if not running Update
3209 
3211  global CHBIsb, RUNstatus, CH2ipdvLevel
3212 
3213  try:
3214  CH2ipdvLevel = float(eval(CHBIsb.get()))
3215  except:
3216  CHBIsb.delete(0,END)
3217  CHBIsb.insert(0, CH2ipdvLevel)
3218  if RUNstatus.get() == 0:
3219  UpdateTimeTrace() # if not running Update
3220 
3221 def BOffsetA(event):
3222  global CHAOffset, CHAVPosEntry, RUNstatus
3223 
3224  try:
3225  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
3226  except:
3227  CHAVPosEntry.delete(0,END)
3228  CHAVPosEntry.insert(0, CHAOffset)
3229  # set new offset level
3230  if RUNstatus.get() == 0:
3231  UpdateTimeTrace() # if not running Update
3232 
3233 def BIOffsetA(event):
3234  global CHAIOffset, CHAIPosEntry, RUNstatus
3235 
3236  try:
3237  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
3238  except:
3239  CHAIPosEntry.delete(0,END)
3240  CHAIPosEntry.insert(0, CHAIOffset)
3241  # set new offset level
3242  if RUNstatus.get() == 0:
3243  UpdateTimeTrace() # if not running Update
3244 
3245 def BOffsetB(event):
3246  global CHBOffset, CHBVPosEntry, RUNstatus
3247 
3248  try:
3249  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
3250  except:
3251  CHBVPosEntry.delete(0,END)
3252  CHBVPosEntry.insert(0, CHBOffset)
3253  # set new offset level
3254  if RUNstatus.get() == 0:
3255  UpdateTimeTrace() # if not running Update
3256 
3257 def BIOffsetB(event):
3258  global CHBIOffset, CHBIPosEntry, RUNstatus
3259 
3260  try:
3261  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
3262  except:
3263  CHBIPosEntry.delete(0,END)
3264  CHBIPosEntry.insert(0, CHBIOffset)
3265  # set new offset level
3266  if RUNstatus.get() == 0:
3267  UpdateTimeTrace() # if not running Update
3268 
3270  global TimeDisp, ckb1
3271  if TimeDisp.get() == 1:
3272  ckb1.config(style="Enab.TCheckbutton")
3273  else:
3274  ckb1.config(style="Disab.TCheckbutton")
3275 #
3277  global XYDisp, ckb2
3278  if XYDisp.get() == 1:
3279  ckb2.config(style="Enab.TCheckbutton")
3280  else:
3281  ckb2.config(style="Disab.TCheckbutton")
3282 #
3284  global FreqDisp, ckb3, OOTckb3, OOTScreenStatus
3285  if FreqDisp.get() == 1:
3286  if OOTScreenStatus.get() == 0:
3287  ckb3.config(style="Enab.TCheckbutton")
3288  else:
3289  OOTckb3.config(style="Enab.TCheckbutton")
3290  else:
3291  if OOTScreenStatus.get() == 0:
3292  ckb3.config(style="Disab.TCheckbutton")
3293  else:
3294  OOTckb3.config(style="Disab.TCheckbutton")
3295 #
3297  global BodeDisp, ckb5, AWGSync, OOTckb5, OOTScreenStatus
3298  if BodeDisp.get() == 1:
3299  AWGSync.set(1)
3300  if OOTScreenStatus.get() == 0:
3301  ckb5.config(style="Enab.TCheckbutton")
3302  else:
3303  OOTckb5.config(style="Enab.TCheckbutton")
3304  else:
3305  if OOTScreenStatus.get() == 0:
3306  ckb5.config(style="Disab.TCheckbutton")
3307  else:
3308  OOTckb5.config(style="Disab.TCheckbutton")
3309 #
3311  global IADisp, ckb4, OOTckb4, OOTScreenStatus
3312  if IADisp.get() == 1:
3313  if OOTScreenStatus.get() == 0:
3314  ckb4.config(style="Enab.TCheckbutton")
3315  else:
3316  OOTckb4.config(style="Enab.TCheckbutton")
3317  else:
3318  if OOTScreenStatus.get() == 0:
3319  ckb4.config(style="Disab.TCheckbutton")
3320  else:
3321  OOTckb4.config(style="Disab.TCheckbutton")
3322 #
3324  global PhADisp, Phckb, OOTphckb, OOTScreenStatus
3325  if PhADisp.get() == 1:
3326  if OOTScreenStatus.get() == 0:
3327  phckb.config(style="Enab.TCheckbutton")
3328  else:
3329  OOTphckb.config(style="Enab.TCheckbutton")
3330  else:
3331  if OOTScreenStatus.get() == 0:
3332  phckb.config(style="Disab.TCheckbutton")
3333  else:
3334  OOTphckb.config(style="Disab.TCheckbutton")
3335 #
3337  global OhmDisp, ckb6, OOTckb6, OOTScreenStatus
3338  if OhmDisp.get() == 1:
3339  if OOTScreenStatus.get() == 0:
3340  ckb6.config(style="Enab.TCheckbutton")
3341  else:
3342  OOTckb6.config(style="Enab.TCheckbutton")
3343  else:
3344  if OOTScreenStatus.get() == 0:
3345  ckb6.config(style="Disab.TCheckbutton")
3346  else:
3347  OOTckb6.config(style="Disab.TCheckbutton")
3348 #
3350  global ETSDisp, enb1
3351  if ETSDisp.get() == 1:
3352  enb1.config(style="Enab.TCheckbutton")
3353  else:
3354  try:
3355  enb1.config(style="Disab.TCheckbutton")
3356  except:
3357  donothing()
3358 # ========================= Main routine ====================================
3359 
3361  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
3362  global PhADisp, IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
3363  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
3364  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
3365  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
3366  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3367  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3368  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3369  global SV1, SI1, SV2, SI2, SVA_B, Closed
3370  global FregPoint, FBins, FStep, TRACEaverage
3371  # Analog Mux channel measurement variables
3372  global TRACEresetTime, TRACEmodeTime, TgInput, SettingsStatus, TRIGGERsample
3373  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode
3374  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3375  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3376  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3377  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3378  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3379 
3380  while (Closed == 0): # Main loop
3381  # RUNstatus = 1 : Open Acquisition
3382  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
3383  if SettingsStatus.get() == 1:
3384  SettingsUpdate() # Make sure current entries in Settings controls are up to date
3385  if TimeDisp.get() > 0 or XYDisp.get() > 0 or PhADisp.get() > 0:
3386  if MuxScreenStatus.get() == 0:
3387  MuxChan = -1
3388  Analog_Time_In()
3389  else:
3390  MuxChan = 0
3391  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
3392  AWGAIOMode.set(1)
3393  AWGBIOMode.set(1)
3394  ShowC1_V.set(0) # force A voltage trace off
3395  ShowC2_V.set(0) # force B voltage trace off
3396  if HWRevOne == "D" :
3397  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
3398  AWGBMode.set(2)
3399  if AWGBIOMode.get() == 0: # if not in split I/O mode
3400  ShowC2_I.set(0) # no need to show CH-B current
3401  if MuxEnb.get() == 1:
3402  PIO2 = 0x51
3403  else:
3404  PIO2 = 0x50
3405  if MuxSync.get() == 0:
3406  PIO3 = 0x51
3407  PIO3x = 0x50
3408  else:
3409  PIO3 = 0x50
3410  PIO3x = 0x51
3411  #
3412  if ChopMuxMode.get() == 0: # do this if in alternate sweep mode
3413  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3414  TRACEresetTime = True # Clear the memory for averaging
3415  if Show_CBA.get() == 1:
3416  MuxChan = 0
3417  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3418  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3419  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
3420  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
3421  time.sleep(0.002)
3422  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3423  if TRACEmodeTime.get() == 1:
3424  if TRACEresetTime == True:
3425  TRACEresetTime = False
3426  # Save previous trace in memory for average trace
3427  VmemoryMuxA = VBuffMA
3428  Analog_Time_In()
3429  if Show_CBB.get() == 1:
3430  MuxChan = 1
3431  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3432  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3433  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3434  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3435  time.sleep(0.002)
3436  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
3437  if TRACEmodeTime.get() == 1:
3438  if TRACEresetTime == True:
3439  TRACEresetTime = False
3440  # Save previous trace in memory for average trace
3441  VmemoryMuxB = VBuffMB
3442  Analog_Time_In()
3443  if Show_CBC.get() == 1:
3444  MuxChan = 2
3445  if DualMuxMode.get() == 1:
3446  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3447  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3448  else:
3449  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3450  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3451  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3452  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3453  time.sleep(0.002)
3454  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3455  if TRACEmodeTime.get() == 1:
3456  if TRACEresetTime == True:
3457  TRACEresetTime = False
3458  # Save previous trace in memory for average trace
3459  VmemoryMuxC = VBuffMC
3460  Analog_Time_In()
3461  if Show_CBD.get() == 1:
3462  MuxChan = 3
3463  if DualMuxMode.get() == 1:
3464  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3465  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3466  else:
3467  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3468  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3469  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3470  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3471  time.sleep(0.002)
3472  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3473  if TRACEmodeTime.get() == 1:
3474  if TRACEresetTime == True:
3475  TRACEresetTime = False
3476  # Save previous trace in memory for average trace
3477  VmemoryMuxD = VBuffMD
3478  Analog_Time_In()
3479  if Show_CBA.get() == 0 and Show_CBB.get() == 0 and Show_CBC.get() == 0 and Show_CBD.get() == 0 and ShowC1_V.get() == 1:
3480  Analog_Time_In()
3481  else: # do this if in Chop mode
3482  MuxChan = 0
3483  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO_2 enable control
3484  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3485  TRACEresetTime = True # Clear the memory for averaging
3486  elif TRACEmodeTime.get() == 1:
3487  if TRACEresetTime == True:
3488  TRACEresetTime = False
3489  # Save previous traces in memory for average trace
3490  VmemoryMuxA = VBuffMA
3491  VmemoryMuxB = VBuffMB
3492  VmemoryMuxC = VBuffMC
3493  VmemoryMuxD = VBuffMD
3494  Analog_Time_In()
3495  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
3496  if IADisp.get() > 0 or BodeDisp.get() > 0:
3497  CutDC.set(1) # remove DC portion of waveform
3498  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
3499  if BodeDisp.get() > 0:
3500  if LoopNum.get() <= len(FStep):
3501  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3502  if FregPoint <= 5.0:
3503  SMPfft = 32768*2
3504  elif FregPoint <= 10.0:
3505  SMPfft = 32768
3506  elif FregPoint < 100.0:
3507  SMPfft = 16384
3508  elif FregPoint < 500.0:
3509  SMPfft = 8192
3510  elif FregPoint < 2000.0:
3511  SMPfft = 4096
3512  else:
3513  SMPfft = 2048
3514  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
3515  SMPfft = SMPfft * 2
3516 
3517  Analog_Freq_In()
3518  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
3519  Ohm_Analog_In()
3520  root.update_idletasks()
3521  root.update()
3522 
3524  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
3525  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
3526  global AWGAIOMode, AWGBIOMode, Two_X_Sample
3527 
3528 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3529  try:
3530  InOffA = float(eval(CHAVOffsetEntry.get()))
3531  except:
3532  CHAVOffsetEntry.delete(0,END)
3533  CHAVOffsetEntry.insert(0, InOffA)
3534  try:
3535  InGainA = float(eval(CHAVGainEntry.get()))
3536  except:
3537  CHAVGainEntry.delete(0,END)
3538  CHAVGainEntry.insert(0, InGainA)
3539  try:
3540  InOffB = float(eval(CHBVOffsetEntry.get()))
3541  except:
3542  CHBVOffsetEntry.delete(0,END)
3543  CHBVOffsetEntry.insert(0, InOffB)
3544  try:
3545  InGainB = float(eval(CHBVGainEntry.get()))
3546  except:
3547  CHBVGainEntry.delete(0,END)
3548  CHBVGainEntry.insert(0, InGainB)
3549  try:
3550  CurOffA = float(CHAIOffsetEntry.get())
3551  except:
3552  CurOffA = 0.0
3553  try:
3554  CurOffB = float(CHBIOffsetEntry.get())
3555  except:
3556  CurOffB = 0.0
3557  try:
3558  CurGainA = float(CHAIGainEntry.get())
3559  except:
3560  CurGainA = 1.0
3561  try:
3562  CurGainB = float(CHBIGainEntry.get())
3563  except:
3564  CurGainB = 1.0
3565  try:
3566  chatestv = float(eval(CHATestVEntry.get()))
3567  if chatestv > 5.0:
3568  chatestv = 5.0
3569  CHATestVEntry.delete(0,END)
3570  CHATestVEntry.insert(0, chatestv)
3571  except:
3572  CHATestVEntry.delete(0,END)
3573  CHATestVEntry.insert(0, chatestv)
3574  try:
3575  chatestr = float(eval(CHATestREntry.get()))
3576  except:
3577  CHATestREntry.delete(0,END)
3578  CHATestREntry.insert(0, chatestr)
3579  #
3580  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
3581  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
3582  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
3583  SetADC_Mux()
3584  # set A and B channels
3585  AWGAMode.set(0) # Set AWG A to SVMI
3586  AWGAShape.set(0) # DC
3587  AWGBMode.set(2) # Set AWG B to Hi-Z
3588  AWGAIOMode.set(0) # turn off Split I/O mode
3589  AWGBIOMode.set(0) # turn off Split I/O mode
3590  AWGAOffsetEntry.delete(0,"end")
3591  AWGAOffsetEntry.insert(0, chatestv)
3592  BAWGAModeLabel()
3593  BAWGBModeLabel() # update AWG labels
3594 
3595  if RMode.get() == 0:
3596  AWGBTerm.set(0)
3597  else:
3598  AWGBTerm.set(1)
3599  #
3600  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3601  if discontloop > 0:
3602  session.flush()
3603  else:
3604  discontloop = 1
3605  time.sleep(0.01)
3606  BAWGEnab()
3607  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
3608  # time.sleep(1000.0/SHOWsamples)
3609  else: # running in continuous mode
3610  if session.continuous:
3611  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
3612  #
3613  # get_samples returns a list of values for voltage [0] and current [1]
3614  for index in range(200): # calculate average
3615  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
3616  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
3617  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
3618  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
3619 
3620  DCVA0 = DCVA0 / 200.0 # calculate average
3621  DCVB0 = DCVB0 / 200.0 # calculate average
3622  DCIA0 = DCIA0 / 200.0 # calculate average
3623  DCIB0 = DCIB0 / 200.0 # calculate average
3624  DCVA0 = (DCVA0 - InOffA) * InGainA
3625  DCVB0 = (DCVB0 - InOffB) * InGainB
3626  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
3627  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
3628  if RMode.get() == 0: # external resistor
3629  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
3630  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
3631  else: # use internal 50 ohm resistor
3632  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
3633  if DCR < 1000:
3634  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
3635  else:
3636  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
3637  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
3638  OhmA0.config(text = OhmString) # change displayed value
3639  OhmA1.config(text = IAString) # change displayed value
3640 #
3641  time.sleep(0.1)
3642  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3643 
3646  global TIMEdiv, TMsb, TRACEmodeTime, TRACEresetTime, TRACEaverage
3647  global VBuffMA, VmemoryMuxA, VBuffMB, VmemoryMuxB, VBuffMC, VmemoryMuxC, VBuffMD, VmemoryMuxD
3648  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
3649  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
3650  global InOffA, InGainA, InOffB, InGainB
3651  global CurOffA, CurOffB, CurGainA, CurGainB
3652  global PhADisp, PhAScreenStatus, MuxScreenStatus, ChopMuxMode
3653  global First_Slow_sweep, Roll_Mode
3654  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3655 
3656  # get time scale
3657  try:
3658  TIMEdiv = eval(TMsb.get())
3659  except:
3660  TIMEdiv = 0.5
3661  TMsb.delete(0,"end")
3662  TMsb.insert(0,TIMEdiv)
3663  if TIMEdiv < 0.0002:
3664  TIMEdiv = 0.01
3665  #
3666 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3667  try:
3668  InOffA = float(eval(CHAVOffsetEntry.get()))
3669  except:
3670  CHAVOffsetEntry.delete(0,END)
3671  CHAVOffsetEntry.insert(0, InOffA)
3672  try:
3673  InGainA = float(eval(CHAVGainEntry.get()))
3674  except:
3675  CHAVGainEntry.delete(0,END)
3676  CHAVGainEntry.insert(0, InGainA)
3677  try:
3678  InOffB = float(eval(CHBVOffsetEntry.get()))
3679  except:
3680  CHBVOffsetEntry.delete(0,END)
3681  CHBVOffsetEntry.insert(0, InOffB)
3682  try:
3683  InGainB = float(eval(CHBVGainEntry.get()))
3684  except:
3685  CHBVGainEntry.delete(0,END)
3686  CHBVGainEntry.insert(0, InGainB)
3687  try:
3688  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
3689  except:
3690  CurOffA = 0.0
3691  try:
3692  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
3693  except:
3694  CurOffB = 0.0
3695  try:
3696  CurGainA = float(CHAIGainEntry.get())
3697  except:
3698  CurGainA = 1.0
3699  try:
3700  CurGainB = float(CHBIGainEntry.get())
3701  except:
3702  CurGainB = 1.0
3703 # Dedecide which Fast or Slow sweep routine to call
3704  if Roll_Mode.get() > 0: # 200:
3705  Analog_Roll_time() # rolling trace
3706  else:
3707  First_Slow_sweep = 0
3709 #
3710  if PhADisp.get() > 0 and PhAScreenStatus.get() == 1:
3711  Analog_Phase_In()
3712 #
3713 # Process captured time dmain signals to extract magnitude and phase data
3715  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB
3716  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3717  global VAresult, VBresult, IAresult, IBresult, VABresult
3718  global PhaseVA, PhaseVB, PhaseIA, PhaseIB, PhaseVAB
3719  global VMAresult, VMBresult,VMCresult, VMDresult
3720  global PhaseVMA, PhaseVMB, PhaseVMC, PhaseVMD
3721  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3722  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3723  global DCVMuxA, DCVMuxB, DCVMuxC, DCVMuxD
3724  global SHOWsamples, SMPfft, hldn, MuxScreenStatus, MuxChan, ChopMuxMode
3725  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
3726  global FFTwindowshape, ZEROstuffing
3727 
3728  if len(VBuffA) < SMPfft: # put up warning to reduce number of FFT Samples or increase Time/Div time base
3730  #showwarning("WARNING","Redude Number of Samples \n Or Increas Time/Div time base.")
3731  #BStop() # Force Stop loop if running
3732  #return
3733  # Do an FFT on captured voltage and current buffer
3734  StartSmp = hldn
3735  StopSmp = hldn + SMPfft
3737  REX = []
3738  PhaseVA = []
3739  PhaseIA = []
3740  PhaseIB = []
3741  # Convert list to numpy array REX for faster Numpy calculations
3742  # Take the first SMPfft samples of VBuffA
3743  REX = numpy.array(VBuffA[StartSmp:StopSmp]-DCV1) # Make a numpy arry of the list
3744 
3745  # Set Analog level display value MAX value is 5 volts for ALM1000
3746  REX = REX / 5.0
3747 
3748  # Do the FFT window function
3749  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3750  # FFT with numpy
3751  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3752  PhaseVA = numpy.angle(ALL, deg=True) # calculate angle
3753  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3754 
3755  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3756  ALL = ALL[0:le] # So take only first half of the array
3757  PhaseVA = PhaseVA[0:le]
3758  Totalcorr = 7.07106 / SMPfft # RMS For VOLTAGE!
3759  VAresult = Totalcorr * ALL
3760  # check to see if analog Mux is being used?
3761  if MuxScreenStatus.get() == 0:
3762  PhaseVB = []
3763  PhaseVAB = []
3764  # Now VB array
3765  REX = numpy.array(VBuffB[StartSmp:StopSmp]-DCV2) # Make a numpy arry of the list
3766 
3767  # Set Analog level display value MAX value is 5 volts for ALM1000
3768  REX = REX / 5.0
3769 
3770  # Do the FFT window function
3771  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3772 
3773  # FFT with numpy
3774  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3775  PhaseVB = numpy.angle(ALL, deg=True) # calculate angle
3776  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3777 
3778  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3779  ALL = ALL[0:le] # So take only first half of the array
3780  PhaseVB = PhaseVB[0:le]
3781  RMScorr = 7.07106 / SMPfft # For rMS VOLTAGE!
3782  VBresult = RMScorr * ALL
3783 
3784  # Now VAB array
3785  REX = numpy.array(VBuffA[StartSmp:StopSmp]-VBuffB[StartSmp:StopSmp]) # Make a numpy arry of the list
3786  REX = REX - (DCV1-DCV2) # cut any remaining DC
3787  # Set Analog level display value MAX value is 5 volts for ALM1000
3788  REX = REX / 5.0
3789 
3790  # Do the FFT window function
3791  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3792 
3793  # FFT with numpy
3794  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3795  PhaseVAB = numpy.angle(ALL, deg=True) # calculate angle
3796  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3797 
3798  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3799  ALL = ALL[0:le] # So take only first half of the array
3800  PhaseVAB = PhaseVAB[0:le]
3801  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3802  VABresult = RMScorr * ALL
3803  else: # Do FFTs on Mux buffers as needed if MuxScreenStatus.get() > 0:
3804  if MuxChan == 0 or ChopMuxMode.get() > 0: #
3805  PhaseVMA = []
3806  # Now VMuxA array
3807  REX = numpy.array(VBuffMA[StartSmp:StopSmp]-DCVMuxA) # Make a numpy arry of the list
3808 
3809  # Set Analog level display value MAX value is 5 volts for ALM1000
3810  REX = REX / 5.0
3811 
3812  # Do the FFT window function
3813  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3814 
3815  # FFT with numpy
3816  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3817  PhaseVMA = numpy.angle(ALL, deg=True) # calculate angle
3818  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3819 
3820  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3821  ALL = ALL[0:le] # So take only first half of the array
3822  PhaseVMA = PhaseVMA[0:le]
3823  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3824  VMAresult = RMScorr * ALL
3825  if MuxChan == 1 or ChopMuxMode.get() > 0: # MuxChan = 1
3826  PhaseVMB = []
3827  # Now VMuxA array
3828  REX = numpy.array(VBuffMB[StartSmp:StopSmp]-DCVMuxB) # Make a numpy arry of the list
3829 
3830  # Set Analog level display value MAX value is 5 volts for ALM1000
3831  REX = REX / 5.0
3832 
3833  # Do the FFT window function
3834  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3835 
3836  # FFT with numpy
3837  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3838  PhaseVMB = numpy.angle(ALL, deg=True) # calculate angle
3839  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3840 
3841  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3842  ALL = ALL[0:le] # So take only first half of the array
3843  PhaseVMB = PhaseVMB[0:le]
3844  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3845  VMBresult = RMScorr * ALL
3846  if MuxChan == 2 or ChopMuxMode.get() > 0: # MuxChan = 2
3847  PhaseVMC = []
3848  # Now VMuxA array
3849  REX = numpy.array(VBuffMC[StartSmp:StopSmp]-DCVMuxC) # Make a numpy arry of the list
3850 
3851  # Set Analog level display value MAX value is 5 volts for ALM1000
3852  REX = REX / 5.0
3853 
3854  # Do the FFT window function
3855  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3856 
3857  # FFT with numpy
3858  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3859  PhaseVMC = numpy.angle(ALL, deg=True) # calculate angle
3860  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3861 
3862  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3863  ALL = ALL[0:le] # So take only first half of the array
3864  PhaseVMC = PhaseVMC[0:le]
3865  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3866  VMCresult = RMScorr * ALL
3867  if MuxChan == 3 or ChopMuxMode.get() > 0: # MuxChan = 3
3868  PhaseVMD = []
3869  # Now VMuxA array
3870  REX = numpy.array(VBuffMD[StartSmp:StopSmp]-DCVMuxD) # Make a numpy arry of the list
3871 
3872  # Set Analog level display value MAX value is 5 volts for ALM1000
3873  REX = REX / 5.0
3874 
3875  # Do the FFT window function
3876  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3877 
3878  # FFT with numpy
3879  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3880  PhaseVMD = numpy.angle(ALL, deg=True) # calculate angle
3881  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3882 
3883  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3884  ALL = ALL[0:le] # So take only first half of the array
3885  PhaseVMD = PhaseVMD[0:le]
3886  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3887  VMDresult = RMScorr * ALL
3888  # Now IA array
3889  REX = numpy.array(IBuffA[StartSmp:StopSmp]) # -DCI1 Make a numpy arry of the list
3890 
3891  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3892  REX = REX / 0.5
3893 
3894  # Do the FFT window function
3895  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3896 
3897  # FFT with numpy
3898  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3899  PhaseIA = numpy.angle(ALL, deg=True) # calculate angle
3900  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3901 
3902  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3903  ALL = ALL[0:le] # So take only first half of the array
3904  PhaseIA = PhaseIA[0:le]
3905  RMScorr = 0.707106 / SMPfft # RMS For current!
3906  IAresult = RMScorr * ALL
3907 
3908  # Now IB array
3909  REX = numpy.array(IBuffB[StartSmp:StopSmp]) # -DCI2 Make a numpy arry of the list
3910 
3911  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3912  REX = REX / 0.5
3913 
3914  # Do the FFT window function
3915  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3916 
3917  # FFT with numpy
3918  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3919  PhaseIB = numpy.angle(ALL, deg=True) # calculate angle
3920  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3921 
3922  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3923  ALL = ALL[0:le] # So take only first half of the array
3924  PhaseIB = PhaseIB[0:le]
3925  RMScorr = 0.707106 / SMPfft # RMS For current!
3926  IBresult = RMScorr * ALL
3927 #
3928  UpdatePhAAll()
3929 #
3930 # Right now this is a limited attempt to plot rolling sweep.
3932  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3933  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3934  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
3935  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3936  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3937  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3938  global CHA, CHB, session, devx, discontloop, contloop
3939  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, Roll_Mode # , ShiftPointer
3940  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3941  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, GRW
3942  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3943  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3944  global SCREENrefresh, DCrefresh
3945  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3946  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3947  global SV1, SI1, SV2, SI2, SVA_B
3948  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3949  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3950  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3951  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3952  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3953  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3954  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3955  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3956  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3957  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3958  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3959  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3960  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3961  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3962  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3963  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3964  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3965  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3966  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3967  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3968  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3969 
3970  # Starting acquisition
3971  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
3972  #
3973  NumSamples = 10 # int(SAMPLErate/TIMEdiv)
3974  if First_Slow_sweep == 0:
3975  VBuffA = numpy.ones(GRW)
3976  VBuffB = numpy.ones(GRW)
3977  IBuffA = numpy.ones(GRW)
3978  IBuffB = numpy.ones(GRW)
3979  DBuff0 = numpy.ones(GRW)
3980  DBuff1 = numpy.ones(GRW)
3981  DBuff2 = numpy.ones(GRW)
3982  DBuff3 = numpy.ones(GRW)
3983  First_Slow_sweep = 1
3984  if len(VBuffA) != GRW:
3985  VBuffA = numpy.ones(GRW)
3986  VBuffB = numpy.ones(GRW)
3987  IBuffA = numpy.ones(GRW)
3988  IBuffB = numpy.ones(GRW)
3989  DBuff0 = numpy.ones(GRW)
3990  DBuff1 = numpy.ones(GRW)
3991  DBuff2 = numpy.ones(GRW)
3992  DBuff3 = numpy.ones(GRW)
3993  #
3994  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3995  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3996  if discontloop > 0:
3997  session.flush()
3998  else:
3999  discontloop = 1
4000  BAWGEnab()
4001  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
4002  # waite to finish then return to open termination
4003  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4004  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4005  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4006  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4007 
4008  else: # running in continuous mode
4009  if session.continuous:
4010  if MuxScreenStatus.get() > 0:
4011  devx.flush(-1, True)
4012  DummySamples = NumSamples*2
4013  if DummySamples < 10000:
4014  DummySamples = 10000
4015  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4016  ADsignal1 = devx.read(NumSamples, -1, True) # True) get samples for both channel A and B
4017  #
4018  else:
4019  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
4020  # Shift one sample
4021 
4026  for index in range(NumSamples): # calculate average
4027  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
4028  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
4029  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
4030  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
4031  DCVA0 = DCVA0/(NumSamples) # calculate V average
4032  DCVB0 = DCVB0/(NumSamples) # calculate V average
4033  DCIA0 = DCIA0/(NumSamples) # calculate I average
4034  DCIB0 = DCIB0/(NumSamples) # calculate I average
4035  #
4036  #
4037  DCVA0 = (DCVA0 - InOffA) * InGainA
4038  DCVB0 = (DCVB0 - InOffB) * InGainB
4039  DCIA0 = (DCIA0 - CurOffA) * CurGainA
4040  DCIB0 = (DCIB0 - CurOffB) * CurGainB
4041  DCIA0 = DCIA0 * 1000 # convert to mA
4042  DCIB0 = DCIB0 * 1000 # convert to mA
4043 # next new sample
4044 
4057  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
4058  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
4059  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
4060  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
4061 # Make digital input buffer if that port is an input
4062  if D0.get() == 0:
4063  DBuff0 = shift_buffer(DBuff0, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100))
4064  if D1.get() == 0:
4065  DBuff1 = shift_buffer(DBuff1, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100))
4066  if D2.get() == 0:
4067  DBuff2 = shift_buffer(DBuff2, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100))
4068  if D3.get() == 0:
4069  DBuff3 = shift_buffer(DBuff3, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100))
4070 # Calculate measurement values
4071  DCV1 = numpy.mean(VBuffA)
4072  DCV2 = numpy.mean(VBuffB)
4073  DCI1 = numpy.mean(IBuffA)
4074  DCI2 = numpy.mean(IBuffB)
4075 # find min and max values
4076  MinV1 = numpy.amin(VBuffA)
4077  MaxV1 = numpy.amax(VBuffA)
4078  MinV2 = numpy.amin(VBuffB)
4079  MaxV2 = numpy.amax(VBuffB)
4080  MinI1 = numpy.amin(IBuffA)
4081  MaxI1 = numpy.amax(IBuffA)
4082  MinI2 = numpy.amin(IBuffB)
4083  MaxI2 = numpy.amax(IBuffB)
4084 # RMS value = square root of average of the data record squared
4085  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA)))
4086  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA)))
4087  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB)))
4088  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB)))
4089  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA-VBuffB)))
4090 #
4091  if TimeDisp.get() > 0:
4092  MakeTimeTrace() # Update the traces
4093  UpdateTimeScreen() # Update the screen
4094  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4095  UpdateXYAll() # Update Data, trace and XY screen
4096  if MeasureStatus.get() > 0:
4098  # update screens
4099 #
4101  global ADsignal1, VBuffMA, VBuffMB, VBuffMC, VBuffMD
4102  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4103  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4104  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4105  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4106  global SHOWsamples, ChopModeFilter
4107 
4108  VBuffMA = [] # Clear the Mux A array
4109  VBuffMB = [] # Clear the Mux B array
4110  VBuffMC = [] # Clear the Mux C array
4111  VBuffMD = [] # Clear the Mux D array
4112  index = 1
4113  while index < SHOWsamples-3: # build arrays VBuffMA, VBuffMB, VBuffMC, VBuffMD
4114  pointer = 0
4115  while pointer < 4:
4116  VBuffMA.append(ADsignal1[index+3][0][0]) # chop AIN into Mux A and B
4117  VBuffMB.append(ADsignal1[index+1][0][0])
4118  VBuffMC.append(ADsignal1[index+3][1][0]) # chop BIN into Mux C and D
4119  VBuffMD.append(ADsignal1[index+1][1][0])
4120  pointer = pointer + 1
4121  index = index + 4
4122  VBuffMA = numpy.array(VBuffMA)
4123  VBuffMB = numpy.array(VBuffMB)
4124  VBuffMC = numpy.array(VBuffMC)
4125  VBuffMD = numpy.array(VBuffMD)
4126  # apply a digital filter to interpolate back to 100 KSPS
4127  VBuffMA = numpy.pad(VBuffMA, (4, 0), "edge")
4128  VBuffMA = numpy.convolve(VBuffMA, ChopModeFilter )
4129  VBuffMA = numpy.roll(VBuffMA, -4)
4130  VBuffMB = numpy.pad(VBuffMB, (4, 0), "edge")
4131  VBuffMB = numpy.convolve(VBuffMB, ChopModeFilter)
4132  VBuffMB = numpy.roll(VBuffMB, -6)
4133  VBuffMC = numpy.pad(VBuffMC, (4, 0), "edge")
4134  VBuffMC = numpy.convolve(VBuffMC, ChopModeFilter )
4135  VBuffMC = numpy.roll(VBuffMC, -4)
4136  VBuffMD = numpy.pad(VBuffMD, (4, 0), "edge")
4137  VBuffMD = numpy.convolve(VBuffMD, ChopModeFilter )
4138  VBuffMD = numpy.roll(VBuffMD, -6)
4139  # calculate waveform scalers
4140  EndSample = SHOWsamples-4
4141  DCVMuxA = numpy.mean(VBuffMA[:EndSample])
4142  MinVMuxA = numpy.amin(VBuffMA[:EndSample])
4143  MaxVMuxA = numpy.amax(VBuffMA[:EndSample])
4144  MidVMuxA = (MaxVMuxA+MinVMuxA)/2.0
4145  PPVMuxA = MaxVMuxA-MinVMuxA
4146 #
4147  DCVMuxB = numpy.mean(VBuffMB[:EndSample])
4148  MinVMuxB = numpy.amin(VBuffMB[:EndSample])
4149  MaxVMuxB = numpy.amax(VBuffMB[:EndSample])
4150  MidVMuxB = (MaxVMuxB+MinVMuxB)/2.0
4151  PPVMuxB = MaxVMuxB-MinVMuxB
4152 #
4153  DCVMuxC = numpy.mean(VBuffMC[:EndSample])
4154  MinVMuxC = numpy.amin(VBuffMC[:EndSample])
4155  MaxVMuxC = numpy.amax(VBuffMC[:EndSample])
4156  MidVMuxC = (MaxVMuxC+MinVMuxC)/2.0
4157  PPVMuxC = MaxVMuxC-MinVMuxC
4158 #
4159  DCVMuxD = numpy.mean(VBuffMD[:EndSample])
4160  MinVMuxD = numpy.amin(VBuffMD[:EndSample])
4161  MaxVMuxD = numpy.amax(VBuffMD[:EndSample])
4162  MidVMuxD = (MaxVMuxD+MinVMuxD)/2.0
4163  PPVMuxD = MaxVMuxD-MinVMuxD
4164  # RMS value = square root of average of the data record squared
4165  SVMuxA = numpy.sqrt(numpy.mean(numpy.square(VBuffMA[:EndSample])))
4166  SVMuxB = numpy.sqrt(numpy.mean(numpy.square(VBuffMB[:EndSample])))
4167  SVMuxC = numpy.sqrt(numpy.mean(numpy.square(VBuffMC[:EndSample])))
4168  SVMuxD = numpy.sqrt(numpy.mean(numpy.square(VBuffMD[:EndSample])))
4169 #
4170 # routine for time scales faster than Slow_Sweep_Limit mSec/Div
4172  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4173  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4174  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4175  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4176  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4177  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
4178  global TRACES, TRACESread, TRACEsize, TRIGGERsampleAltA, TRIGGERsampleAltB
4179  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4180  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
4181  global SAMPLErate, SHOWsamples, SMPfft, MinSamples, MaxSamples, AWGSAMPLErate
4182  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4183  global SCREENrefresh, DCrefresh, ETSrecord
4184  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4185  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4186  global SV1, SI1, SV2, SI2, SVA_B
4187  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4188  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4189  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4190  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4191  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4192  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
4193  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4194  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4195  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4196  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4197  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4198  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4199  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4200  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode, ChopTrig
4201  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4202  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4203  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4204  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4205  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4206  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4207  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4208  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4209  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
4210 
4211  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
4212  TRACEresetTime = True # Clear the memory for averaging
4213  elif TRACEmodeTime.get() == 1:
4214  if TRACEresetTime == True:
4215  TRACEresetTime = False
4216  # Save previous trace in memory for average trace
4217  VmemoryA = VBuffA
4218  VmemoryB = VBuffB
4219  ImemoryA = IBuffA
4220  ImemoryB = IBuffB
4221 
4222  try:
4223  HoldOff = float(eval(HoldOffentry.get()))
4224  if HoldOff < 0:
4225  HoldOff = 0
4226  HoldOffentry.delete(0,END)
4227  HoldOffentry.insert(0, HoldOff)
4228  except:
4229  HoldOffentry.delete(0,END)
4230  HoldOffentry.insert(0, HoldOff)
4231 #
4232  try:
4233  HozPoss = float(eval(HozPossentry.get()))
4234  except:
4235  HozPossentry.delete(0,END)
4236  HozPossentry.insert(0, HozPoss)
4237 
4238  hldn = int(HoldOff * SAMPLErate/1000 )
4239  hozpos = int(HozPoss * SAMPLErate/1000 )
4240  if hozpos < 0:
4241  hozpos = 0
4242  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
4243  onescreen = int(twoscreens/2)
4244  if hldn+hozpos > MaxSamples-twoscreens:
4245  hldn = MaxSamples-twoscreens-hozpos
4246  HoldOffentry.delete(0,END)
4247  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
4248  if ETSDisp.get() > 0:
4249  if TIMEdiv > 0.2:
4250  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
4251  else:
4252  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
4253  if (MaxETSrecord*100) > MaxSamples:
4254  MaxETSrecord = MaxSamples / 100
4255  try:
4256  DivX = float(eval(DivXEntry.get()))
4257  if DivX < 2:
4258  DivX = 2
4259  if DivX > 75:
4260  DivX = 75
4261  DivXEntry.delete(0,END)
4262  DivXEntry.insert(0, DivX)
4263  except:
4264  DivXEntry.delete(0,END)
4265  DivXEntry.insert(0, DivX)
4266  FOff = 25
4267  MulX = (DivX*SAMPLErate)/(100*FOff)
4268  while MulX > MaxETSrecord:
4269  FOff = FOff + 5
4270  MulX = (DivX*SAMPLErate)/(100*FOff)
4271  FOff = 0 - FOff
4272  if DeBugMode > 0:
4273  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
4274  MulXEntry.config(text = SRstring) # change displayed value
4275  SRstring = "Offset = " + str(FOff) + " samples"
4276  FOffEntry.config(text = SRstring) # change displayed value
4277  SHOWsamples = int(MulX * 100)
4278  else:
4279  SHOWsamples = twoscreens + hldn + hozpos
4280  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
4281  SHOWsamples = MaxSamples
4282  if SHOWsamples < MinSamples: # or a Min of 1000 samples
4283  SHOWsamples = MinSamples
4284  if PhAScreenStatus.get() > 0:
4285  if SHOWsamples < SMPfft:
4286  SHOWsamples = SMPfft + hldn + hozpos
4287  if hozpos >= 0:
4288  TRIGGERsample = hldn
4289  else:
4290  TRIGGERsample = abs(hozpos)
4291  TRIGGERsample = TRIGGERsample + hozpos #
4292 # Starting acquisition
4293  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4294  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4295  if discontloop > 0:
4296  session.flush()
4297  else:
4298  discontloop = 1
4299  time.sleep(0.01)
4300  BAWGEnab()
4301  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4302  # waite to finish then return to open termination
4303  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4304  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4305  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4306  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4307  else: # running in continuous mode
4308  if session.continuous:
4309  if MuxScreenStatus.get() > 0:
4310  devx.flush(-1, True)
4311  DummySamples = SHOWsamples*2
4312  if DummySamples < 20000:
4313  DummySamples = 20000
4314  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4315  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
4316  #
4317  else:
4318  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
4319  # waite to finish then return to open termination
4320  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4321  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4322  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4323  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4324  #
4325  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4326  if ADC_Mux_Mode.get() == 0: # VA and VB
4327  VBuffA = [] # Clear the V Buff array for trace A
4328  VBuffB = [] # Clear the V Buff array for trace B
4329  elif ADC_Mux_Mode.get() == 1: # IA and IB
4330  IBuffA = [] # Clear the I Buff array for trace A
4331  IBuffB = [] # Clear the I Buff array for trace B
4332  elif ADC_Mux_Mode.get() == 4: # VA and IA
4333  VBuffA = [] # Clear the V Buff array for trace A
4334  IBuffA = [] # Clear the I Buff array for trace A
4335  elif ADC_Mux_Mode.get() == 5: # VB and IB
4336  VBuffB = [] # Clear the V Buff array for trace B
4337  IBuffB = [] # Clear the I Buff array for trace B
4338  else:
4339  VBuffA = [] # Clear the V Buff array for trace A
4340  IBuffA = [] # Clear the I Buff array for trace A
4341  VBuffB = [] # Clear the V Buff array for trace B
4342  IBuffB = [] # Clear the I Buff array for trace B
4343  increment = 1
4344  # SAMPLErate = 200000 #AWGSAMPLErate
4345  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
4346  increment = 2
4347  SAMPLErate = int(AWGSAMPLErate/increment)
4348  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
4349  increment = 4
4350  SAMPLErate = int(AWGSAMPLErate/increment)
4351  index = 0
4352  if SHOWsamples != len(ADsignal1):
4353  SHOWsamples = len(ADsignal1)
4354 #
4355  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0: # check to see if Mux Chop mode is set
4357 #
4358  while index < SHOWsamples: # build arrays and decimate if needed
4359  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
4360  if ADC_Mux_Mode.get() == 0: # VA and VB
4361  VBuffA.append(ADsignal1[index][0][0])
4362  VBuffA.append(ADsignal1[index][1][1])
4363  VBuffB.append(ADsignal1[index][0][1])
4364  VBuffB.append(ADsignal1[index][1][0])
4365  if Alternate_Sweep_Mode.get() == 0:
4366  IBuffA.append(0.0) # fill as a place holder
4367  IBuffA.append(0.0) # fill as a place holder
4368  IBuffB.append(0.0) # fill as a place holder
4369  IBuffB.append(0.0) # fill as a place holder
4370  elif ADC_Mux_Mode.get() == 1: # IA and IB
4371  IBuffA.append(ADsignal1[index][0][1])
4372  IBuffA.append(ADsignal1[index][1][0])
4373  IBuffB.append(ADsignal1[index][0][0])
4374  IBuffB.append(ADsignal1[index][1][1])
4375  if Alternate_Sweep_Mode.get() == 0:
4376  VBuffA.append(0.0) # fill as a place holder
4377  VBuffA.append(0.0) # fill as a place holder
4378  VBuffB.append(0.0) # fill as a place holder
4379  VBuffB.append(0.0) # fill as a place holder
4380  elif ADC_Mux_Mode.get() == 2: # VA and IB
4381  VBuffA.append((ADsignal1[index][0][1])/1024.0)
4382  VBuffA.append((ADsignal1[index][1][0])/1024.0)
4383  #
4384  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
4385  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
4386  #
4387  if Alternate_Sweep_Mode.get() == 0:
4388  VBuffB.append(0.0) # fill as a place holder
4389  VBuffB.append(0.0) # fill as a place holder
4390  IBuffA.append(0.0) # fill as a place holder
4391  IBuffA.append(0.0) # fill as a place holder
4392  elif ADC_Mux_Mode.get() == 3: # VB and IA
4393  VBuffB.append((ADsignal1[index][0][0])/1024.0)
4394  VBuffB.append((ADsignal1[index][1][1])/1024.0)
4395  #
4396  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
4397  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
4398  #
4399  if Alternate_Sweep_Mode.get() == 0:
4400  VBuffA.append(0.0) # fill as a place holder
4401  VBuffA.append(0.0) # fill as a place holder
4402  IBuffB.append(0.0) # fill as a place holder
4403  IBuffB.append(0.0) # fill as a place holder
4404  elif ADC_Mux_Mode.get() == 4: # VA and IA
4405  VBuffA.append(ADsignal1[index][0][0])
4406  VBuffA.append(ADsignal1[index][1][1])
4407  IBuffA.append(ADsignal1[index][0][1])
4408  IBuffA.append(ADsignal1[index][1][0])
4409  if Alternate_Sweep_Mode.get() == 0:
4410  VBuffB.append(0.0) # fill as a place holder
4411  VBuffB.append(0.0) # fill as a place holder
4412  IBuffB.append(0.0) # fill as a place holder
4413  IBuffB.append(0.0) # fill as a place holder
4414  elif ADC_Mux_Mode.get() == 5: # VB and IB
4415  VBuffB.append(ADsignal1[index][0][1])
4416  VBuffB.append(ADsignal1[index][1][0])
4417  IBuffB.append(ADsignal1[index][0][0])
4418  IBuffB.append(ADsignal1[index][1][1])
4419  if Alternate_Sweep_Mode.get() == 0:
4420  VBuffA.append(0.0) # fill as a place holder
4421  VBuffA.append(0.0) # fill as a place holder
4422  IBuffA.append(0.0) # fill as a place holder
4423  IBuffA.append(0.0) # fill as a place holder
4424  else:
4425  VBuffA.append(ADsignal1[index][0][0])
4426  IBuffA.append(ADsignal1[index][0][1])
4427  VBuffB.append(ADsignal1[index][1][0])
4428  IBuffB.append(ADsignal1[index][1][1])
4429  index = index + increment
4430 #
4431  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4432  if len(VBuffA) < 4:
4433  index = 0
4434  while index < SHOWsamples:
4435  VBuffA.append(0.0) # fill as a place holder
4436  index = index + increment
4437  if len(VBuffB) < 4:
4438  index = 0
4439  while index < SHOWsamples:
4440  VBuffB.append(0.0) # fill as a place holder
4441  index = index + increment
4442  if len(IBuffA) < 4:
4443  index = 0
4444  while index < SHOWsamples:
4445  IBuffA.append(0.0) # fill as a place holder
4446  index = index + increment
4447  if len(IBuffB) < 4:
4448  index = 0
4449  while index < SHOWsamples:
4450  IBuffB.append(0.0) # fill as a place holder
4451  index = index + increment
4452 #
4453  if ADC_Mux_Mode.get() == 0: # VA and VB
4454  VBuffA = numpy.array(VBuffA)
4455  VBuffB = numpy.array(VBuffB)
4456  VBuffA = (VBuffA - InOffA) * InGainA
4457  VBuffB = (VBuffB - InOffB) * InGainB
4458  ADC_Mux_Mode.set(1) # switch mode
4459  Last_ADC_Mux_Mode = 0
4460  elif ADC_Mux_Mode.get() == 1: # IA and IB
4461  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4462  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4463  IBuffA = (IBuffA - CurOffA) * CurGainA
4464  IBuffB = (IBuffB - CurOffB) * CurGainB
4465  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
4466  elif ADC_Mux_Mode.get() == 4: # VA and IA
4467  VBuffA = numpy.array(VBuffA)
4468  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4469  IBuffA = (IBuffA - CurOffA) * CurGainA
4470  VBuffA = (VBuffA - InOffA) * InGainA
4471  ADC_Mux_Mode.set(1) # switch mode
4472  Last_ADC_Mux_Mode = 4
4473  elif ADC_Mux_Mode.get() == 5: # VB and IB
4474  VBuffB = numpy.array(VBuffB)
4475  VBuffB = (VBuffB - InOffB) * InGainB
4476  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4477  IBuffB = (IBuffB - CurOffB) * CurGainB
4478  ADC_Mux_Mode.set(1) # switch mode
4479  Last_ADC_Mux_Mode = 5
4480  SetADC_Mux()
4481  #
4482  else:
4483  VBuffA = numpy.array(VBuffA)
4484  VBuffB = numpy.array(VBuffB)
4485  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4486  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4487  VBuffA = (VBuffA - InOffA) * InGainA
4488  VBuffB = (VBuffB - InOffB) * InGainB
4489  IBuffA = (IBuffA - CurOffA) * CurGainA
4490  IBuffB = (IBuffB - CurOffB) * CurGainB
4491  TRACESread = 2
4492  SHOWsamples = len(VBuffA)
4493 # temp ETS calculations
4494  if ETSDisp.get() > 0:
4495  baseFreq = SAMPLErate/DivX
4496  #
4497  VAets = []
4498  VBets = []
4499  IAets = []
4500  IBets = []
4501  index = 0
4502  try:
4503  FMul = float(eval(FminEntry.get()))
4504  if FMul < 1:
4505  FMul = 1
4506  FMulXEntry.delete(0,END)
4507  FMulXEntry.insert(0, int(FMul))
4508  if FMul > 75:
4509  FMul = 75
4510  FMulXEntry.delete(0,END)
4511  FMulXEntry.insert(0, int(FMul))
4512  except:
4513  FMulXEntry.delete(0,END)
4514  FMulXEntry.insert(0, int(FMul))
4515  Fmin = baseFreq * FMul
4516  FminE = float(SAMPLErate + FOff)
4517  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
4518  # length of record set my Multiplcation factor
4519  tot_cycles = int((MulX*100)/Samples_Cycle)
4520  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
4521  ETSrecord = int((MulX*50)/Samples_Cycle)
4522  if tot_cycles > SHOWsamples:
4523  tot_cycles = SHOWsamples-1
4524  # now sort RT data into ETS sample buffers
4525  while index < SHOWsamples:
4526  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
4527  IndexValue = int(tot_cycles * Dpart)
4528  if IndexValue > SHOWsamples:
4529  IndexValue = SHOWsamples-1
4530  if IndexValue > tot_cycles:
4531  IndexValue = tot_cycles
4532  if ETSDir.get() == 0:
4533  VAets.append(VBuffA[IndexValue])
4534  VBets.append(VBuffB[IndexValue])
4535  IAets.append(IBuffA[IndexValue])
4536  IBets.append(IBuffB[IndexValue])
4537  else:
4538  VAets.append(VBuffA[int(tot_cycles-IndexValue)])
4539  VBets.append(VBuffB[int(tot_cycles-IndexValue)])
4540  IAets.append(IBuffA[int(tot_cycles-IndexValue)])
4541  IBets.append(IBuffB[int(tot_cycles-IndexValue)])
4542  index = index + 1
4543  SHiftFact = 5
4544  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
4545  VBuffA = VAets
4546  VBuffB = VBets
4547  IBuffA = IAets
4548  IBuffB = IBets
4549  VBuffA = numpy.array(VBuffA)
4550  VBuffB = numpy.array(VBuffB)
4551  IBuffA = numpy.array(IBuffA)
4552  IBuffB = numpy.array(IBuffB)
4553  try:
4554  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
4555  except:
4556  TimeCorrection = SHiftFact
4557  if ETSDir.get() == 0:
4558  VBuffB = numpy.roll(VBuffB, TimeCorrection)
4559  IBuffB = numpy.roll(IBuffB, TimeCorrection)
4560  else:
4561  VBuffB = numpy.roll(VBuffB, TimeCorrection)
4562  IBuffB = numpy.roll(IBuffB, TimeCorrection)
4563  SHOWsamples = twoscreens + hldn + hozpos
4564 # Check if Input channel RC high pass compensation checked
4565  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
4566  try:
4567  TC1A = float(cha_TC1Entry.get())
4568  if TC1A < 0:
4569  TC1A = 0
4570  cha_TC1Entry.delete(0,END)
4571  cha_TC1Entry.insert(0, TC1A)
4572  except:
4573  TC1A = CHA_TC1.get()
4574  try:
4575  TC2A = float(cha_TC2Entry.get())
4576  if TC2A < 0:
4577  TC2A = 0
4578  cha_TC2Entry.delete(0,END)
4579  cha_TC2Entry.insert(0, TC2A)
4580  except:
4581  TC2A = CHA_TC2.get()
4582  #
4583  try:
4584  Gain1A = float(cha_A1Entry.get())
4585  except:
4586  Gain1A = CHA_A1.get()
4587  try:
4588  Gain2A = float(cha_A2Entry.get())
4589  except:
4590  Gain2A = CHA_A2.get()
4591  #
4592  if len(VBuffA) > 4:
4593  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
4594  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
4595  if CHAI_RC_HP.get() == 1:
4596  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
4597  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
4598  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
4599  try:
4600  TC1B = float(chb_TC1Entry.get())
4601  if TC1B < 0:
4602  TC1B = 0
4603  chb_TC1Entry.delete(0, END)
4604  chb_TC1Entry.insert(0, TC1B)
4605  except:
4606  TC1B = CHB_TC1.get()
4607  try:
4608  TC2B = float(chb_TC2Entry.get())
4609  if TC2B < 0:
4610  TC2B = 0
4611  chb_TC2Entry.delete(0, END)
4612  chb_TC2Entry.insert(0, TC2B)
4613  except:
4614  TC2B = CHB_TC2.get()
4615  #
4616  try:
4617  Gain1B = float(chb_A1Entry.get())
4618  except:
4619  Gain1B = CHB_A1.get()
4620  try:
4621  Gain2B = float(chb_A2Entry.get())
4622  except:
4623  Gain2B = CHB_A2.get()
4624  #
4625  if len(VBuffB) > 4:
4626  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
4627  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
4628  if CHBI_RC_HP.get() == 1:
4629  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
4630  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
4631 # Check if need to DeSkew waveform data
4632  if DigDeSkewA.get() > 0:
4633  Shift = int(BCASkewEntry.get())
4634  if Shift != 0:
4635  VBuffA = numpy.roll(VBuffA, Shift)
4636  if DigDeSkewB.get() > 0:
4637  Shift = int(BCBSkewEntry.get())
4638  if Shift != 0:
4639  VBuffB = numpy.roll(VBuffB, Shift)
4640 # check if digital filter box checked
4641  if DigFiltA.get() == 1:
4642  if len(DFiltACoef) > 1:
4643  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
4644  if DigFiltB.get() == 1:
4645  if len(DFiltBCoef) > 1:
4646  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
4647 # Find trigger sample point if necessary
4648  LShift = 0
4649  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0:
4650  if ChopTrig.get() == 1:
4651  FindTriggerSample(VBuffMA)
4652  if ChopTrig.get() == 2:
4653  FindTriggerSample(VBuffMB)
4654  if ChopTrig.get() == 3:
4655  FindTriggerSample(VBuffMC)
4656  if ChopTrig.get() == 4:
4657  FindTriggerSample(VBuffMD)
4658  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4659  # Average mode 1, add difference / TRACEaverage to array
4660  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0:
4661  LShift = 0 - TRIGGERsample
4662  VBuffMA = numpy.roll(VBuffMA, LShift)
4663  VBuffMB = numpy.roll(VBuffMB, LShift)
4664  VBuffMC = numpy.roll(VBuffMC, LShift)
4665  VBuffMD = numpy.roll(VBuffMD, LShift)
4666  IBuffA = numpy.roll(IBuffA, LShift)
4667  IBuffB = numpy.roll(IBuffB, LShift)
4668  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4669  if ChopTrig.get() == 1:
4670  ReInterploateTrigger(VBuffMA)
4671  if ChopTrig.get() == 2:
4672  ReInterploateTrigger(VBuffMB)
4673  if ChopTrig.get() == 3:
4674  ReInterploateTrigger(VBuffMC)
4675  if ChopTrig.get() == 4:
4676  ReInterploateTrigger(VBuffMD)
4677  else:
4678  if TgInput.get() == 1:
4679  FindTriggerSample(VBuffA)
4680  if TgInput.get() == 2:
4681  FindTriggerSample(IBuffA)
4682  if TgInput.get() == 3:
4683  FindTriggerSample(VBuffB)
4684  if TgInput.get() == 4:
4685  FindTriggerSample(IBuffB)
4686  if TgInput.get() == 5:
4687  FindTriggerSample(VBuffA)
4688  if Is_Triggered == 0: # Trigger event not found for VBuffA so Try VBuffB
4689  FindTriggerSample(VBuffB)
4690  if TgInput.get() == 6:
4691  FindTriggerSample(VBuffA)
4692  TRIGGERsampleAltA = TRIGGERsample
4693  FindTriggerSample(VBuffB)
4694  TRIGGERsampleAltB = TRIGGERsample
4695  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4696  # Average mode 1, add difference / TRACEaverage to array
4697  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
4698  LShift = 0 - TRIGGERsample
4699  if TgInput.get() == 6:
4700  LShift = 0 - TRIGGERsampleAltA
4701  VBuffA = numpy.roll(VBuffA, LShift)
4702  IBuffA = numpy.roll(IBuffA, LShift)
4703  LShift = 0 - TRIGGERsampleAltB
4704  VBuffB = numpy.roll(VBuffB, LShift)
4705  IBuffB = numpy.roll(IBuffB, LShift)
4706  else:
4707  VBuffA = numpy.roll(VBuffA, LShift)
4708  VBuffB = numpy.roll(VBuffB, LShift)
4709  IBuffA = numpy.roll(IBuffA, LShift)
4710  IBuffB = numpy.roll(IBuffB, LShift)
4711  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4712  try:
4713  if DualMuxMode.get() == 0: # and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
4714  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
4715  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
4716  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
4717  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
4718  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
4719  except:
4720  # buffer size mismatch so reset memory buffers
4721  VmemoryA = VBuffA
4722  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
4723  VmemoryB = VBuffB
4724  ImemoryA = IBuffA
4725  ImemoryB = IBuffB
4726  if TgInput.get() == 1 or TgInput.get() == 5 or TgInput.get() == 6:
4727  ReInterploateTrigger(VBuffA)
4728  if TgInput.get() == 2:
4729  ReInterploateTrigger(IBuffA)
4730  if TgInput.get() == 3 or TgInput.get() == 5 or TgInput.get() == 6:
4731  ReInterploateTrigger(VBuffB)
4732  if TgInput.get() == 4:
4733  ReInterploateTrigger(IBuffB)
4734 # DC value = average of the data record
4735  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
4736  Endsample = hldn+onescreen # average over only one screen's worth of samples
4737  else:
4738  Endsample = SHOWsamples - 10 # average over all samples
4739  if MeasGateStatus.get() == 1:
4740  if (MeasGateRight-MeasGateLeft) > 0:
4741  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
4742  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
4743  if Endsample <= hldn:
4744  Endsample = hldn + 2
4745 # Calculate VA scalar values
4746  DCV1 = numpy.mean(VBuffA[hldn:Endsample])
4747  DCV2 = numpy.mean(VBuffB[hldn:Endsample])
4748  DCI1 = numpy.mean(IBuffA[hldn:Endsample])
4749  DCI2 = numpy.mean(IBuffB[hldn:Endsample])
4750 # find min and max values
4751  MinV1 = numpy.amin(VBuffA[hldn:Endsample])
4752  MaxV1 = numpy.amax(VBuffA[hldn:Endsample])
4753  MinV2 = numpy.amin(VBuffB[hldn:Endsample])
4754  MaxV2 = numpy.amax(VBuffB[hldn:Endsample])
4755  MinI1 = numpy.amin(IBuffA[hldn:Endsample])
4756  MaxI1 = numpy.amax(IBuffA[hldn:Endsample])
4757  MinI2 = numpy.amin(IBuffB[hldn:Endsample])
4758  MaxI2 = numpy.amax(IBuffB[hldn:Endsample])
4759 # RMS value = square root of average of the data record squared
4760  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample])))
4761  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[hldn:Endsample])))
4762  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[hldn:Endsample])))
4763  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[hldn:Endsample])))
4764  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample]-VBuffB[hldn:Endsample])))
4765 # Transfer to mux buffers as necessary
4766  if TgInput.get() > 0 and TRACEmodeTime.get() != 1: # and MuxChan > -1
4767  # if triggering left shift all arrays such that trigger point is at index 0
4768  LShift = 0 - TRIGGERsample
4769  VBuffA = numpy.roll(VBuffA, LShift)
4770  VBuffB = numpy.roll(VBuffB, LShift)
4771  IBuffA = numpy.roll(IBuffA, LShift)
4772  IBuffB = numpy.roll(IBuffB, LShift)
4773  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4774  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0 and TRACEmodeTime.get() != 1:
4775  LShift = 0 - TRIGGERsample
4776  VBuffMA = numpy.roll(VBuffMA, LShift)
4777  VBuffMB = numpy.roll(VBuffMB, LShift)
4778  VBuffMC = numpy.roll(VBuffMC, LShift)
4779  VBuffMD = numpy.roll(VBuffMD, LShift)
4780  IBuffA = numpy.roll(IBuffA, LShift)
4781  IBuffB = numpy.roll(IBuffB, LShift)
4782  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4783  if ChopMuxMode.get() == 1 and TRACEmodeTime.get() == 1: # also if in chop mode cal avaerage
4784  # Average mode 1, add difference / TRACEaverage to array
4785  try:
4786  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
4787  except: # buffer size mismatch so reset memory buffers
4788  VmemoryMuxA = VBuffMA
4789  try:
4790  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
4791  except: # buffer size mismatch so reset memory buffers
4792  VmemoryMuxB = VBuffMB
4793  try:
4794  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
4795  except: # buffer size mismatch so reset memory buffers
4796  VmemoryMuxC = VBuffMC
4797  try:
4798  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
4799  except: # buffer size mismatch so reset memory buffers
4800  VmemoryMuxD = VBuffMD
4801  if MuxChan > -1 and ChopMuxMode.get() == 0: # do this when not in chop mux mode
4802  if Show_CBA.get() == 1 and MuxChan == 0: # Dval0[0] == 0 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
4803  DCVMuxA = DCV2
4804  MinVMuxA = MinV2
4805  MaxVMuxA = MaxV2
4806  MidVMuxA = (MaxV2+MinV2)/2.0
4807  PPVMuxA = MaxV2-MinV2
4808  SVMuxA = SV2
4809  VBuffMA = VBuffB
4810  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4811  # Average mode 1, add difference / TRACEaverage to array
4812  try:
4813  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
4814  except:
4815  # buffer size mismatch so reset memory buffers
4816  VmemoryMuxA = VBuffMA
4817  if Show_CBB.get() == 1 and MuxChan == 1: # Dval0[0] == 1 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
4818  DCVMuxB = DCV2
4819  MinVMuxB = MinV2
4820  MaxVMuxB = MaxV2
4821  MidVMuxB = (MaxV2+MinV2)/2.0
4822  PPVMuxB = MaxV2-MinV2
4823  SVMuxB = SV2
4824  VBuffMB = VBuffB
4825  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4826  # Average mode 1, add difference / TRACEaverage to array
4827  try:
4828  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
4829  except:
4830  # buffer size mismatch so reset memory buffers
4831  VmemoryMuxB = VBuffMB
4832  if Show_CBC.get() == 1 and MuxChan == 2: #and Dval0[0] == 0 and Dval1[0] == 1
4833  if DualMuxMode.get() == 1 :
4834  DCVMuxC = DCV1
4835  MinVMuxC = MinV1
4836  MaxVMuxC = MaxV1
4837  MidVMuxC = (MaxV1+MinV1)/2.0
4838  PPVMuxC = MaxV1-MinV1
4839  SVMuxC = SV1
4840  VBuffMC = VBuffA
4841  else:
4842  DCVMuxC = DCV2
4843  MinVMuxC = MinV2
4844  MaxVMuxC = MaxV2
4845  MidVMuxC = (MaxV2+MinV2)/2.0
4846  PPVMuxC = MaxV2-MinV2
4847  SVMuxC = SV2
4848  VBuffMC = VBuffB
4849  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4850  # Average mode 1, add difference / TRACEaverage to array
4851  try:
4852  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
4853  except:
4854  # buffer size mismatch so reset memory buffers
4855  VmemoryMuxC = VBuffMC
4856  if Show_CBD.get() == 1 and MuxChan == 3: #and Dval0[0] == 1 and Dval1[0] == 1
4857  if DualMuxMode.get() == 1 :
4858  DCVMuxD = DCV1
4859  MinVMuxD = MinV1
4860  MaxVMuxD = MaxV1
4861  MidVMuxD = (MaxV1+MinV1)/2.0
4862  PPVMuxD = MaxV1-MinV1
4863  SVMuxD = SV1
4864  VBuffMD = VBuffA
4865  else:
4866  DCVMuxD = DCV2
4867  MinVMuxD = MinV2
4868  MaxVMuxD = MaxV2
4869  MidVMuxD = (MaxV2+MinV2)/2.0
4870  PPVMuxD = MaxV2-MinV2
4871  SVMuxD = SV2
4872  VBuffMD = VBuffB
4873  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4874  # Average mode 1, add difference / TRACEaverage to array
4875  try:
4876  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
4877  except:
4878  # buffer size mismatch so reset memory buffers
4879  VmemoryMuxD = VBuffMD
4880  # update screens
4881  if TimeDisp.get() > 0:
4882  # Check if in non functional state of 2X samplerate and 3 or more traces amd not enabled AWGSync
4883  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
4884  if NumTraces > 2 and AWGSync.get() == 0 and Two_X_Sample.get() == 1:
4885  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
4886  BStop()
4887  # return
4888  UpdateTimeAll() # Update Data, trace and time screen
4889  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4890  UpdateXYAll() # Update Data, trace and XY screen
4891  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
4892  BStop() #
4893  SingleShot.set(0)
4894  if ManualTrigger.get() == 1: # Manual trigger is on
4895  BStop() #
4896  if MeasureStatus.get() > 0:
4898 #
4899 # Function to calculate relative phase angle between two sine waves of the same frequency
4900 # Removes any DC content
4902  global DCV1, DCV2, VBuffA, VBuffB
4903 
4904  sum1 = 0.0
4905  sum2 = 0.0
4906  sum12 = 0.0
4907  i = 0
4908  n = len(VBuffA)
4909  while i < n:
4910  sum1 += (VBuffA[i]-DCV1)*(VBuffA[i]-DCV1)
4911  sum2 += (VBuffB[i]-DCV2)*(VBuffB[i]-DCV2)
4912  sum12 += (VBuffA[i]-DCV1)*(VBuffB[i]-DCV2)
4913  i += 1
4914  return math.acos(sum12/math.sqrt(sum1*sum2))*180.0/numpy.pi
4915 #
4916 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
4917 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
4918 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
4919 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
4920 
4921 
4923 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
4924  global SAMPLErate, Two_X_Sample
4925 
4926  OutBuff = []
4927  n = len(InBuff)
4928  if Two_X_Sample.get() == 0:
4929  Delta = 1.0/SAMPLErate
4930  else: # adjust for sligh difference in 2X sample mode?
4931  Delta = 0.88/SAMPLErate
4932  TC = TC1 * 1.0E-6
4933  Alpha = TC / (TC + Delta)
4934  OutBuff.append(0.0) # initialize first output sample
4935  i = 1
4936  while i < n:
4937  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
4938  i += 1
4939  OutBuff = numpy.array(OutBuff)
4940  OutBuff = InBuff + (OutBuff * Gain)
4941  return OutBuff
4942 
4944 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
4945  global SAMPLErate
4946 
4947  OutBuff = []
4948  n = len(InBuff)
4949  Delta = 1.0/SAMPLErate
4950  TC = TC1 * 1.0E-6
4951  Alpha = Delta / (TC + Delta)
4952  i = 1
4953  OutBuff.append(Alpha*InBuff[0])
4954  while i < n:
4955  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
4956  i += 1
4957  OutBuff = numpy.array(OutBuff)
4958  OutBuff = (OutBuff * Gain)
4959  return OutBuff
4960 
4964 def shift_buffer(arr, num, fill_value=numpy.nan):
4965  result = numpy.empty_like(arr)
4966  if num > 0:
4967  result[:num] = fill_value
4968  result[num:] = arr[:-num]
4969  elif num < 0:
4970  result[num:] = fill_value
4971  result[:num] = arr[-num:]
4972  else:
4973  result[:] = arr
4974  return result
4975 
4976 
4979  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
4980  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
4981  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
4982  global NSteps, LoopNum, FSweepMode, FStep, FBins
4983  global StartFreqEntry, StopFreqEntry, HoldOffentry
4984  global session, CHA, CHB, devx, MaxSamples, discontloop
4985  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
4986  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
4987  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
4988  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
4989  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
4990  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4991  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
4992  global BDSweepFile, FileSweepFreq, FileSweepAmpl
4993  global PIO_0, PIO_1, PIO_2, PIO_3
4994  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
4995  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4996  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4997  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4998  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
4999 
5000  HalfSAMPLErate = SAMPLErate/2
5001  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
5002  try:
5003  InOffA = float(eval(CHAVOffsetEntry.get()))
5004  except:
5005  CHAVOffsetEntry.delete(0,END)
5006  CHAVOffsetEntry.insert(0, InOffA)
5007  try:
5008  InGainA = float(eval(CHAVGainEntry.get()))
5009  except:
5010  CHAVGainEntry.delete(0,END)
5011  CHAVGainEntry.insert(0, InGainA)
5012  try:
5013  InOffB = float(eval(CHBVOffsetEntry.get()))
5014  except:
5015  CHBVOffsetEntry.delete(0,END)
5016  CHBVOffsetEntry.insert(0, InOffB)
5017  try:
5018  InGainB = float(eval(CHBVGainEntry.get()))
5019  except:
5020  CHBVGainEntry.delete(0,END)
5021  CHBVGainEntry.insert(0, InGainB)
5022  try:
5023  HoldOff = float(eval(HoldOffentry.get()))
5024  if HoldOff < 0:
5025  HoldOff = 0
5026  HoldOffentry.delete(0,END)
5027  HoldOffentry.insert(0, HoldOff)
5028  except:
5029  HoldOffentry.delete(0,END)
5030  HoldOffentry.insert(0, HoldOff)
5031  #
5032  INITIALIZEstart()
5033  # Starting acquisition This is a HACK to get around non-continous AWG mode!
5034  # restart AWGs if indicated
5035  if BodeDisp.get() == 0: # make new noise waveforms each sweep
5036  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
5037  AWGAMakeUUNoise()
5038  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
5039  AWGAMakeUGNoise()
5040  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
5041  AWGBMakeUUNoise()
5042  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
5043  AWGBMakeUGNoise()
5044  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
5045  if BDSweepFile.get() == 0:
5046  if LoopNum.get() <= len(FStep):
5047  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
5048  else:
5049  FregPoint = FBins[FStep[0]]
5050  else:
5051  if LoopNum.get() <= len(FileSweepFreq): #
5052  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
5053  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
5054  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
5055  else:
5056  FregPoint = FBins[FileSweepFreq[0]]
5057  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
5058  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
5059  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
5060  if FSweepMode.get() == 1: # set new CH-A amplitude
5061  AWGAAmplEntry.delete(0,END)
5062  AWGAAmplEntry.insert(4, VMin)
5063  AWGAOffsetEntry.delete(0,END)
5064  AWGAOffsetEntry.insert(4, VMax)
5065  if FSweepMode.get() == 2: # set new CH-B amplitude
5066  AWGBAmplEntry.delete(0,END)
5067  AWGBAmplEntry.insert(4, VMin)
5068  AWGBOffsetEntry.delete(0,END)
5069  AWGBOffsetEntry.insert(4, VMax)
5070  if FSweepMode.get() == 1: # set new CH-A frequency
5071  AWGAFreqEntry.delete(0,END)
5072  AWGAFreqEntry.insert(4, FregPoint)
5074  if FSweepMode.get() == 2: # set new CH-B frequency
5075  AWGBFreqEntry.delete(0,END)
5076  AWGBFreqEntry.insert(4, FregPoint)
5078  if FSweepMode.get() == 3: # set new MiniGen frequency
5079  MinigenFout.delete(0,END)
5080  MinigenFout.insert(4, FregPoint)
5081  BSendMG()
5082  if AWGSync.get() > 0:
5083  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5084  if Two_X_Sample.get() == 1:
5085  AWGBIOMode.set(1)
5086  AWGBMode.set(0)
5087  else:
5088  AWGBMode.set(2)
5089  # BAWGEnab()
5090 #
5091  hldn = int(HoldOff * 100 )
5092  if hldn > MaxSamples-SMPfft:
5093  hldn = MaxSamples-SMPfft
5094  HoldOffentry.delete(0,END)
5095  HoldOffentry.insert(0, hldn/100)
5096  if hldn < 128:
5097  hldn = 128
5098  SHOWsamples = SMPfft + hldn # get holf off extra samples
5099  if BodeDisp.get() > 0: # check if doing Bode Plot
5100  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
5101  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5102  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5103  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5104  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
5105  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5106  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5107  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5108  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
5109  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5110  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5111  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5112  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
5113  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5114  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5115  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5116  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
5117  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5118  if Two_X_Sample.get() == 1:
5119  AWGBIOMode.set(1)
5120  AWGBMode.set(0)
5121  else:
5122  AWGBMode.set(2)
5123  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
5124  if discontloop > 0:
5125  session.flush()
5126  else:
5127  discontloop = 1
5128  BAWGEnab()
5129  try:
5130  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5131  except:
5132  donothing()
5133  # waite to finish then return to open termination
5134  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5135  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5136  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5137  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5138  else: # running in continuous mode
5139  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
5140  #
5141  else:
5142  if session.continuous:
5143  ADsignal1 = devx.read(SHOWsamples, -1, True)
5144  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5145  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5146  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5147  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5148  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5149  FFTBuffA = [] # Clear the FFTBuff array for trace A
5150  FFTBuffB = [] # Clear the FFTBuff array for trace B
5151  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
5152  index = hldn # skip first hldn samples
5153  if SHOWsamples != len(ADsignal1):
5154  SHOWsamples = len(ADsignal1)
5155  while index < SHOWsamples:
5156  if Two_X_Sample.get() == 1:
5157  if ADC_Mux_Mode.get() == 0: # VA and VB
5158  FFTBuffA.append(ADsignal1[index][0][0])
5159  FFTBuffA.append(ADsignal1[index][1][1])
5160  FFTBuffB.append(ADsignal1[index][0][1])
5161  FFTBuffB.append(ADsignal1[index][1][0])
5162  else:
5163  VAdata = ADsignal1[index][0][0]
5164  FFTBuffA.append(VAdata)
5165  VBdata = ADsignal1[index][1][0]
5166  FFTBuffB.append(VBdata)
5167  if VAdata > 5.0 or VAdata < 0.0:
5168  OverRangeFlagA = 1
5169 
5170  if VBdata > 5.0 or VBdata < 0.0:
5171  OverRangeFlagB = 1
5172  index = index + 1
5173 
5174  FFTBuffA = numpy.array(FFTBuffA)
5175  FFTBuffB = numpy.array(FFTBuffB)
5176  FFTBuffA = (FFTBuffA - InOffA) * InGainA
5177  FFTBuffB = (FFTBuffB - InOffB) * InGainB
5178  DCA = numpy.average(FFTBuffA)
5179  DCB = numpy.average(FFTBuffB)
5180  if CutDC.get() == 1:
5181  FFTBuffA = FFTBuffA - DCA
5182  FFTBuffB = FFTBuffB - DCB
5183 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5184  if CHA_RC_HP.get() == 1:
5185  try:
5186  TC1A = float(cha_TC1Entry.get())
5187  if TC1A < 0:
5188  TC1A = 0
5189  cha_TC1Entry.delete(0,END)
5190  cha_TC1Entry.insert(0, TC1A)
5191  except:
5192  TC1A = CHA_TC1.get()
5193  try:
5194  TC2A = float(cha_TC2Entry.get())
5195  if TC2A < 0:
5196  TC2A = 0
5197  cha_TC2Entry.delete(0,END)
5198  cha_TC2Entry.insert(0, TC2A)
5199  except:
5200  TC2A = CHA_TC2.get()
5201  #
5202  try:
5203  Gain1A = float(cha_A1Entry.get())
5204  except:
5205  Gain1A = CHA_A1.get()
5206  try:
5207  Gain2A = float(cha_A2Entry.get())
5208  except:
5209  Gain2A = CHA_A2.get()
5210  #
5211  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
5212  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
5213  if CHB_RC_HP.get() == 1:
5214  try:
5215  TC1B = float(chb_TC1Entry.get())
5216  if TC1B < 0:
5217  TC1B = 0
5218  chb_TC1Entry.delete(0, END)
5219  chb_TC1Entry.insert(0, TC1B)
5220  except:
5221  TC1B = CHB_TC1.get()
5222  try:
5223  TC2B = float(chb_TC2Entry.get())
5224  if TC2B < 0:
5225  TC2B = 0
5226  chb_TC2Entry.delete(0, END)
5227  chb_TC2Entry.insert(0, TC2B)
5228  except:
5229  TC2B = CHB_TC2.get()
5230  #
5231  try:
5232  Gain1B = float(chb_A1Entry.get())
5233  except:
5234  Gain1B = CHB_A1.get()
5235  try:
5236  Gain2B = float(chb_A2Entry.get())
5237  except:
5238  Gain2B = CHB_A2.get()
5239  #
5240  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
5241  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
5242 # check if digital filter box checked
5243  if DigFiltA.get() == 1:
5244  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
5245  if DigFiltB.get() == 1:
5246  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
5247  DoFFT()
5248  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
5249  UpdateFreqAll() # Update spectrum Data, trace and screen
5250  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
5251  UpdateIAAll()
5252  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
5253  UpdateBodeAll()
5254  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
5255  UpdateNqPAll()
5256  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
5257  UpdateNiCAll()
5258  if SingleShotSA.get() == 1: # Single shot sweep is on
5259  RUNstatus.set(0)
5260 #
5261  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
5262  LoopNum.set(LoopNum.get() + 1)
5263  if LoopNum.get() > NSteps.get():
5264  if FSweepMode.get() == 1:
5265  AWGAFreqEntry.delete(0,"end")
5266  AWGAFreqEntry.insert(0, Reset_Freq)
5267  if FSweepMode.get() == 2:
5268  AWGBFreqEntry.delete(0,"end")
5269  AWGBFreqEntry.insert(0, Reset_Freq)
5270 #
5271  LoopNum.set(1)
5272  if FSweepCont.get() == 0:
5273  RUNstatus.set(0)
5274 #
5275 
5277  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
5278  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
5279  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
5280  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5281  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5282  global VABase, VATop, VBBase, VBTop
5283 
5284  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
5285  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
5286  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
5287  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
5288  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
5289  LowerPeak = 0
5290  UpperPeak = 0
5291  b = 0
5292  while (b < 4999):
5293  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
5294  LowerPeak = b
5295  VABase = HBuffA[1][b]
5296  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
5297  UpperPeak = b
5298  VATop = HBuffA[1][b]
5299  b = b + 1
5300  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
5301  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
5302  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
5303  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
5304  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
5305  LowerPeak = 0
5306  UpperPeak = 0
5307  b = 0
5308  while (b < 4999):
5309  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
5310  LowerPeak = b
5311  VBBase = HBuffB[1][b]
5312  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
5313  UpperPeak = b
5314  VBTop = HBuffB[1][b]
5315  b = b + 1
5316 
5318  global HistAsPercent
5319 
5320  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
5321  HistAsPercent = 1
5322  else:
5323  HistAsPercent = 0
5324 
5325 def FindRisingEdge(Trace1, Trace2):
5326  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
5327  global ETSrecord, DISsamples
5328  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
5329  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
5330  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
5331 
5332  anr1 = bnr1 = 0
5333  anf1 = bnf1 = 1
5334  anr2 = bnr2 = 2
5335  hldn = int(HoldOff * SAMPLErate/1000)
5336  # print(DISsamples, len(Trace1))
5337  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
5338  Trace1 = numpy.roll(Trace1, -LShift)
5339  Trace2 = numpy.roll(Trace2, -LShift)
5340  else:
5341  Trace1 = numpy.roll(Trace1, -hldn)
5342  Trace2 = numpy.roll(Trace2, -hldn)
5343  try:
5344  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
5345  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
5346  except:
5347  MidV1 = (MinV1+MaxV1)/2
5348  MidV2 = (MinV2+MaxV2)/2
5349 # search Trace 1
5350 
5357  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
5358  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
5359  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
5360  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
5361 
5362  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
5363  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
5364 # Catch zero length array?
5365  try:
5366  Dummy_read = Arising[0]
5367  except:
5368  return
5369  if len(Arising) > 0 or len(Afalling) > 0:
5370  if Arising[0] > 0:
5371  try:
5372  anr1 = AIrising[0]
5373  except:
5374  anr1 = 0
5375  try:
5376  anr2 = AIrising[1]
5377  except:
5378  anr2 = SHOWsamples
5379  try:
5380  if AIfalling[0] < AIrising[0]:
5381  anf1 = AIfalling[1]
5382  else:
5383  anf1 = AIfalling[0]
5384  except:
5385  anf1 = 1
5386  else:
5387  try:
5388  anr1 = AIrising[1]
5389  except:
5390  anr1 = 0
5391  try:
5392  anr2 = AIrising[2]
5393  except:
5394  anr2 = SHOWsamples
5395  try:
5396  if AIfalling[1] < AIrising[1]:
5397  anf1 = AIfalling[2]
5398  else:
5399  anf1 = AIfalling[1]
5400  except:
5401  anf1 = 1
5402 # search Trace 2
5403 
5410  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
5411  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
5412  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
5413  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
5414 
5415  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
5416  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
5417 # Catch zero length array?
5418  try:
5419  Dummy_read = Brising[0]
5420  except:
5421  return
5422  if len(Brising) > 0 or len(Bfalling) > 0:
5423  if Brising[0] > 0:
5424  try:
5425  bnr1 = BIrising[0]
5426  except:
5427  bnr1 = 0
5428  try:
5429  bnr2 = BIrising[1]
5430  except:
5431  bnr2 = SHOWsamples
5432  try:
5433  if BIfalling[0] < BIrising[0]:
5434  bnf1 = BIfalling[1]
5435  else:
5436  bnf1 = BIfalling[0]
5437  except:
5438  bnf1 = 1
5439  else:
5440  try:
5441  bnr1 = BIrising[1]
5442  except:
5443  bnr1 = 0
5444  try:
5445  bnr2 = BIrising[2]
5446  except:
5447  bnr2 = SHOWsamples
5448  try:
5449  if BIfalling[1] < BIrising[1]:
5450  bnf1 = BIfalling[2]
5451  else:
5452  bnf1 = BIfalling[1]
5453  except:
5454  bnf1 = 1
5455  #
5456  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
5457  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
5458  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
5459  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
5460  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
5461  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
5462 #
5463  if bnr1 > anr1:
5464  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
5465  else:
5466  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
5467  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
5468  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
5469  try:
5470  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
5471  except:
5472  CHABphase = 0.0
5473  if CHABphase < 0.0:
5474  CHABphase = CHABphase + 360.0
5475 
5477  global DX, TRIGGERsample, TRIGGERlevel
5478 
5479  DX = 0
5480  n = TRIGGERsample
5481  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
5482  if DY != 0.0:
5483  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
5484  else:
5485  DX = 0
5486 
5487 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
5488  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
5489  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
5490  global Trigger_LPF_length, LPFTrigger
5491 
5492  # Set the TRACEsize variable
5493  TRACEsize = SHOWsamples # Set the trace length
5494  DX = 0
5495  Is_Triggered = 0
5496  if LPFTrigger.get() > 0:
5497  TFiltCoef = [] # empty coef array
5498  for n in range(Trigger_LPF_length.get()):
5499  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
5500  TFiltCoef = numpy.array(TFiltCoef)
5501  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
5502 
5503  if len(TrgBuff) == 0:
5504  return
5505  try:
5506  TrgMin = numpy.amin(TrgBuff)
5507  except:
5508  TrgMin = 0.0
5509  try:
5510  TrgMax = numpy.amax(TrgBuff)
5511  except:
5512  TrgMax = 0.0
5513 # Find trigger sample
5514  try:
5515  if AutoLevel.get() == 1:
5516  TRIGGERlevel = (TrgMin + TrgMax)/2
5517  TRIGGERentry.delete(0,"end")
5518  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
5519  else:
5520  TRIGGERlevel = eval(TRIGGERentry.get())
5521  except:
5522  TRIGGERentry.delete(0,END)
5523  TRIGGERentry.insert(0, TRIGGERlevel)
5524 # Start from first sample after HoldOff
5525  try:
5526  HoldOff = float(eval(HoldOffentry.get()))
5527  if HoldOff < 0:
5528  HoldOff = 0
5529  HoldOffentry.delete(0,END)
5530  HoldOffentry.insert(0, HoldOff)
5531  except:
5532  HoldOffentry.delete(0,END)
5533  HoldOffentry.insert(0, HoldOff)
5534 # slide trace left right by HozPoss
5535  try:
5536  HozPoss = float(eval(HozPossentry.get()))
5537  except:
5538  HozPossentry.delete(0,END)
5539  HozPossentry.insert(0, HozPoss)
5540 
5541  hldn = int(HoldOff * SAMPLErate/1000)
5542  hozpos = int(HozPoss * SAMPLErate/1000)
5543  if hozpos >= 0:
5544  TRIGGERsample = hldn
5545  else:
5546  TRIGGERsample = abs(hozpos)
5547 #
5548  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
5549  DX = 0
5550  n = TRIGGERsample
5551  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
5552  if TRIGGERlevel2 < TrgMin:
5553  TRIGGERlevel2 = TrgMin
5554  if TRIGGERlevel2 > TrgMax:
5555  TRIGGERlevel2 = TrgMax
5556  ChInput = TrgBuff[int(n)]
5557  Prev = ChInput
5558  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
5559  n = n + 1
5560  ChInput = TrgBuff[int(n)]
5561  while (ChInput <= TRIGGERlevel) and n < Nmax:
5562  Prev = ChInput
5563  n = n + 1
5564  ChInput = TrgBuff[int(n)]
5565  DY = ChInput - Prev
5566  if DY != 0.0:
5567  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
5568  else:
5569  DX = 0
5570  if TgEdge.get() == 1:
5571  TRIGGERlevel2 = 1.01 * TRIGGERlevel
5572  if TRIGGERlevel2 < TrgMin:
5573  TRIGGERlevel2 = TrgMin
5574  if TRIGGERlevel2 > TrgMax:
5575  TRIGGERlevel2 = TrgMax
5576  ChInput = TrgBuff[int(n)]
5577  Prev = ChInput
5578  while (ChInput <= TRIGGERlevel2) and n < Nmax:
5579  n = n + 1
5580  ChInput = TrgBuff[int(n)]
5581  while (ChInput >= TRIGGERlevel) and n < Nmax:
5582  Prev = ChInput
5583  n = n + 1
5584  ChInput = TrgBuff[int(n)]
5585  DY = Prev - ChInput
5586  try:
5587  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
5588  except:
5589  DX = 0
5590 
5591 # check to insure trigger point is in bounds
5592  if n < Nmax:
5593  TRIGGERsample = n - 1
5594  Is_Triggered = 1
5595  elif n > Nmax: # Didn't find edge in first 2/3 of data set
5596  TRIGGERsample = 1 + hldn # reset to begining
5597  Is_Triggered = 0
5598  if DX > 1:
5599  DX = 1 # never more than 100% of a sample period
5600  elif DX < 0:
5601  DX = 0 # never less than 0% of a sample period
5602  if math.isnan(DX):
5603  DX = 0
5604  TRIGGERsample = TRIGGERsample + hozpos
5605 
5607  global win2, DigScreenStatus
5608 
5609  DigScreenStatus.set(0)
5610  win2.destroy()
5611 #
5612 def sel(): # change Digital I/O and update screen color readback
5613  global devx, DevID
5614  global D0, D1, D2, D3, D4, D5, D6, D7
5615  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
5616  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
5617  # sending 0x50 = set to 0, 0x51 = set to 1
5618  if D0.get() > 0:
5619  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
5620  if D0.get() == 0x50:
5621  digin0.configure(text="Low", background="#00ff00")
5622  else:
5623  digin0.configure(text="Hi", background="#ff0000")
5624  else:
5625  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
5626  if Dval[0] == 0:
5627  digin0.configure(text="Low", background="#00ff00")
5628  else:
5629  digin0.configure(text="Hi", background="#ff0000")
5630  if D1.get() > 0:
5631  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
5632  if D1.get() == 0x50:
5633  digin1.configure(text="Low", background="#00ff00")
5634  else:
5635  digin1.configure(text="Hi", background="#ff0000")
5636  else:
5637  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
5638  if Dval[0] == 0:
5639  digin1.configure(text="Low", background="#00ff00")
5640  else:
5641  digin1.configure(text="Hi", background="#ff0000")
5642  if D2.get() > 0:
5643  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
5644  if D2.get() == 0x50:
5645  digin2.configure(text="Low", background="#00ff00")
5646  else:
5647  digin2.configure(text="Hi", background="#ff0000")
5648  else:
5649  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
5650  if Dval[0] == 0:
5651  digin2.configure(text="Low", background="#00ff00")
5652  else:
5653  digin2.configure(text="Hi", background="#ff0000")
5654  if D3.get() > 0:
5655  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
5656  if D3.get() == 0x50:
5657  digin3.configure(text="Low", background="#00ff00")
5658  else:
5659  digin3.configure(text="Hi", background="#ff0000")
5660  else:
5661  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
5662  if Dval[0] == 0:
5663  digin3.configure(text="Low", background="#00ff00")
5664  else:
5665  digin3.configure(text="Hi", background="#ff0000")
5666  if D4.get() > 0:
5667  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
5668  if D4.get() == 0x50:
5669  digin4.configure(text="Low", background="#00ff00")
5670  else:
5671  digin4.configure(text="Hi", background="#ff0000")
5672  else:
5673  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
5674  if Dval[0] == 0:
5675  digin4.configure(text="Low", background="#00ff00")
5676  else:
5677  digin4.configure(text="Hi", background="#ff0000")
5678  if D5.get() > 0:
5679  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
5680  if D5.get() == 0x50:
5681  digin5.configure(text="Low", background="#00ff00")
5682  else:
5683  digin5.configure(text="Hi", background="#ff0000")
5684  else:
5685  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
5686  if Dval[0] == 0:
5687  digin5.configure(text="Low", background="#00ff00")
5688  else:
5689  digin5.configure(text="Hi", background="#ff0000")
5690  if D6.get() > 0:
5691  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
5692  if D6.get() == 0x50:
5693  digin6.configure(text="Low", background="#00ff00")
5694  else:
5695  digin6.configure(text="Hi", background="#ff0000")
5696  else:
5697  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
5698  if Dval[0] == 0:
5699  digin6.configure(text="Low", background="#00ff00")
5700  else:
5701  digin6.configure(text="Hi", background="#ff0000")
5702  if D7.get() > 0:
5703  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
5704  if D7.get() == 0x50:
5705  digin7.configure(text="Low", background="#00ff00")
5706  else:
5707  digin7.configure(text="Hi", background="#ff0000")
5708  else:
5709  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
5710  if Dval[0] == 0:
5711  digin7.configure(text="Low", background="#00ff00")
5712  else:
5713  digin7.configure(text="Hi", background="#ff0000")
5714 
5715 
5717  global D0, D1, D2, D3, D4, D5, D6, D7
5718  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
5719  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
5720  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
5721  # setup Dig output window
5722  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5723  DigScreenStatus.set(1)
5724  win2 = Toplevel()
5725  win2.title("Dig Out")
5726  win2.resizable(FALSE,FALSE)
5727  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
5728  drb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
5729  drb1.grid(row=2, column=0, sticky=W)
5730  drb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
5731  drb0z.grid(row=2, column=1, sticky=W)
5732  drb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
5733  drb2.grid(row=2, column=2, sticky=W)
5734  digin0 = Label(win2, text="Low", background = "#00ff00")
5735  digin0.grid(row=2, column=3, sticky=W)
5736  drb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
5737  drb3.grid(row=3, column=0, sticky=W)
5738  drb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
5739  drb3z.grid(row=3, column=1, sticky=W)
5740  drb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
5741  drb4.grid(row=3, column=2, sticky=W)
5742  digin1 = Label(win2, text="Low", background = "#00ff00")
5743  digin1.grid(row=3, column=3, sticky=W)
5744  drb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
5745  drb5.grid(row=4, column=0, sticky=W)
5746  drb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
5747  drb5z.grid(row=4, column=1, sticky=W)
5748  drb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
5749  drb6.grid(row=4, column=2, sticky=W)
5750  digin2 = Label(win2, text="Low", background = "#00ff00")
5751  digin2.grid(row=4, column=3, sticky=W)
5752  drb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
5753  drb7.grid(row=5, column=0, sticky=W)
5754  drb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
5755  drb7z.grid(row=5, column=1, sticky=W)
5756  drb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
5757  drb8.grid(row=5, column=2, sticky=W)
5758  digin3 = Label(win2, text="Low", background = "#00ff00")
5759  digin3.grid(row=5, column=3, sticky=W)
5760  drb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
5761  drb9.grid(row=6, column=0, sticky=W)
5762  drb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
5763  drb9z.grid(row=6, column=1, sticky=W)
5764  drb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
5765  drb10.grid(row=6, column=2, sticky=W)
5766  digin4 = Label(win2, text="Low", background = "#00ff00")
5767  digin4.grid(row=6, column=3, sticky=W)
5768  drb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
5769  drb11.grid(row=7, column=0, sticky=W)
5770  drb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
5771  drb11z.grid(row=7, column=1, sticky=W)
5772  drb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
5773  drb12.grid(row=7, column=2, sticky=W)
5774  digin5 = Label(win2, text="Low", background = "#00ff00")
5775  digin5.grid(row=7, column=3, sticky=W)
5776  drb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
5777  drb13.grid(row=8, column=0, sticky=W)
5778  drb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
5779  drb13z.grid(row=8, column=1, sticky=W)
5780  drb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
5781  drb13.grid(row=8, column=2, sticky=W)
5782  digin6 = Label(win2, text="Low", background = "#00ff00")
5783  digin6.grid(row=8, column=3, sticky=W)
5784  drb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
5785  drb14.grid(row=9, column=0, sticky=W)
5786  drb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
5787  drb14z.grid(row=9, column=1, sticky=W)
5788  drb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
5789  drb15.grid(row=9, column=2, sticky=W)
5790  digin7 = Label(win2, text="Low", background = "#00ff00")
5791  digin7.grid(row=9, column=3, sticky=W)
5792 
5793  digdismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
5794  digdismissbutton.grid(row=10, column=0, sticky=W)
5795 
5797  global win1, DacScreenStatus
5798 
5799  DacScreenStatus.set(0)
5800  win1.destroy()
5801 
5802 def sel0(temp):
5803  global devx, DevID
5804  global PIO_0, PIO_4
5805  global DAC0
5806  # sending 0x50 = set to 0, 0x51 = set to 1
5807  if DAC0.get() == 1:
5808  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5809  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
5810  elif DAC0.get() == 4:
5811  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5812  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
5813  elif DAC0.get() == 2:
5814  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5815  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5816  elif DAC0.get() == 3:
5817  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
5818  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
5819  elif DAC0.get() == 5:
5820  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
5821  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5822  elif DAC0.get() == 7:
5823  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
5824  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
5825  elif DAC0.get() == 8:
5826  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
5827  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5828  elif DAC0.get() == 6:
5829  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
5830  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
5831  elif DAC0.get() == 9:
5832  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
5833  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
5834 
5835 def sel1(temp):
5836  global devx, DevID
5837  global PIO_1, PIO_5
5838  global DAC1
5839  # sending 0x50 = set to 0, 0x51 = set to 1
5840  if DAC1.get() == 1:
5841  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5842  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
5843  elif DAC1.get() == 4:
5844  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5845  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
5846  elif DAC1.get() == 2:
5847  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5848  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5849  elif DAC1.get() == 3:
5850  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5851  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
5852  elif DAC1.get() == 5:
5853  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5854  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5855  elif DAC1.get() == 7:
5856  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5857  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
5858  elif DAC1.get() == 8:
5859  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
5860  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5861  elif DAC1.get() == 6:
5862  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
5863  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
5864  elif DAC1.get() == 9:
5865  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
5866  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
5867 
5868 def sel2(temp):
5869  global devx, DevID
5870  global PIO_2, PIO_6
5871  global DAC2
5872  # sending 0x50 = set to 0, 0x51 = set to 1
5873  if DAC2.get() == 1:
5874  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5875  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
5876  elif DAC2.get() == 4:
5877  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5878  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5879  elif DAC2.get() == 2:
5880  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5881  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5882  elif DAC2.get() == 3:
5883  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5884  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5885  elif DAC2.get() == 5:
5886  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5887  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5888  elif DAC2.get() == 7:
5889  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5890  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5891  elif DAC2.get() == 8:
5892  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
5893  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5894  elif DAC2.get() == 6:
5895  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5896  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5897  elif DAC2.get() == 9:
5898  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5899  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
5900 
5901 def sel3(temp):
5902  global devx, DevID
5903  global PIO_3, PIO_7
5904  global DAC3
5905  # sending 0x50 = set to 0, 0x51 = set to 1
5906  if DAC3.get() == 1:
5907  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5908  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
5909  elif DAC3.get() == 4:
5910  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5911  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5912  elif DAC3.get() == 2:
5913  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5914  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5915  elif DAC3.get() == 3:
5916  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5917  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5918  elif DAC3.get() == 5:
5919  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5920  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5921  elif DAC3.get() == 7:
5922  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5923  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5924  elif DAC3.get() == 8:
5925  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
5926  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5927  elif DAC3.get() == 6:
5928  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5929  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5930  elif DAC3.get() == 9:
5931  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5932  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
5933 
5935  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
5936  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
5937  # setup Dig output window
5938  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5939  DacScreenStatus.set(1)
5940  win1 = Toplevel()
5941  win1.title("DAC Out "+ SWRev + RevDate)
5942  win1.resizable(FALSE,FALSE)
5943  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
5944  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
5945  DAC0.grid(row=0, column=0, sticky=W)
5946  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
5947  DAC1.grid(row=0, column=1, sticky=W)
5948  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
5949  DAC2.grid(row=0, column=2, sticky=W)
5950  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
5951  DAC3.grid(row=0, column=3, sticky=W)
5952 
5953  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
5954  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
5955 
5957 
5958  MakeTimeTrace() # Update the traces
5959  UpdateTimeScreen() # Update the screen
5960 
5962 
5963  MakeTimeTrace() # Update traces
5964  UpdateTimeScreen() # Update the screen
5965 
5967 
5968  MakeTimeScreen() # Update the screen
5969  root.update() # Activate updated screens
5970 
5972 
5973  MakeXYTrace() # Update the traces
5974  UpdateXYScreen() # Update the screen
5975 
5977 
5978  MakeXYTrace() # Update traces
5979  UpdateXYScreen() # Update the screen
5980 
5982 
5983  MakeXYScreen() # Update the screen
5984  root.update() # Activate updated screens
5985 
5987  global VBuffA, VBuffB, IBuffA, IBuffB
5988  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
5989  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
5990  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
5991  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
5992  global D0line, D1line, D2line, D3line
5993  global FFTBuffA, FFTBuffB, FFTwindowshape
5994  global AWGAwaveform, AWGBwaveform
5995  global T1Vline, T2Vline, T1Iline, T2Iline
5996  global TMAVline, TMBVline, TMCVline, TMDVline
5997  global Tmathline, TMXline, TMYline
5998  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
5999  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
6000  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
6001  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
6002  global SHOWsamples, ZOHold, AWGBMode
6003  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
6004  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
6005  global Show_MathX, Show_MathY
6006  global TRACES, TRACESread, RUNstatus
6007  global AutoCenterA, AutoCenterB
6008  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
6009  global TMpdiv # Array with time / div values in ms
6010  global TMsb # Time per div spin box variable
6011  global TIMEdiv # current spin box value
6012  global SAMPLErate, SCstart, Two_X_Sample, DISsamples, First_Slow_sweep
6013  global TRIGGERsample, TRACEsize, DX, TRIGGERsampleAltA, TRIGGERsampleAltB
6014  global TRIGGERlevel, TRIGGERentry, AutoLevel
6015  global InOffA, InGainA, InOffB, InGainB
6016  global CurOffA, CurOffB, CurGainA, CurGainB
6017  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
6018  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
6019  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6020  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6021  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
6022  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6023  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6024  global HozPoss, HozPossentry
6025 
6026  # Set the TRACEsize variable
6027  if len(VBuffA) < 100 and MuxScreenStatus.get() == 0:
6028  return
6029  TRACEsize = SHOWsamples # Set the trace length
6030  SCstart = 0
6031  ylo = 0.0
6032  xlo = 0.0
6033  Ymin = Y0T # Minimum position of time grid (top)
6034  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6035  Xmin = X0L # Minimum position of time grid (left)
6036  Xmax = X0L + GRW # Maximum position of time grid (right)
6037 
6038  # prevent divide by zero error
6039  if TIMEdiv < 0.0002:
6040  TIMEdiv = 0.01
6041  # Check for Auto Centering
6042  if AutoCenterA.get() > 0:
6043  CHAOffset = DCV1
6044  CHAVPosEntry.delete(0,END)
6045  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
6046  if AutoCenterB.get() > 0:
6047  CHBOffset = DCV2
6048  CHBVPosEntry.delete(0,END)
6049  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
6050  # get the vertical ranges
6051  try:
6052  CH1pdvRange = float(eval(CHAsb.get()))
6053  except:
6054  CHAsb.delete(0,END)
6055  CHAsb.insert(0, CH1pdvRange)
6056  try:
6057  CH2pdvRange = float(eval(CHBsb.get()))
6058  except:
6059  CHBsb.delete(0,END)
6060  CHBsb.insert(0, CH2pdvRange)
6061  try:
6062  CH1IpdvRange = float(eval(CHAIsb.get()))
6063  except:
6064  CHAIsb.delete(0,END)
6065  CHAIsb.insert(0, CH1IpdvRange)
6066  try:
6067  CH2IpdvRange = float(eval(CHBIsb.get()))
6068  except:
6069  CHBIsb.delete(0,END)
6070  CHBIsb.insert(0, CH2IpdvRange)
6071  # get the vertical offsets
6072  try:
6073  CHAOffset = float(eval(CHAVPosEntry.get()))
6074  except:
6075  CHAVPosEntry.delete(0,END)
6076  CHAVPosEntry.insert(0, CHAOffset)
6077  try:
6078  CHAIOffset = float(eval(CHAIPosEntry.get()))
6079  except:
6080  CHAIPosEntry.delete(0,END)
6081  CHAIPosEntry.insert(0, CHAIOffset)
6082  try:
6083  CHBOffset = float(eval(CHBVPosEntry.get()))
6084  except:
6085  CHBVPosEntry.delete(0,END)
6086  CHBVPosEntry.insert(0, CHBOffset)
6087  try:
6088  CHBIOffset = float(eval(CHBIPosEntry.get()))
6089  except:
6090  CHBIPosEntry.delete(0,END)
6091  CHBIPosEntry.insert(0, CHBIOffset)
6092  # prevent divide by zero error
6093  if CH1pdvRange < 0.001:
6094  CH1pdvRange = 0.001
6095  if CH2pdvRange < 0.001:
6096  CH2pdvRange = 0.001
6097  if CH1IpdvRange < 0.1:
6098  CH1IpdvRange = 0.1
6099  if CH2IpdvRange < 0.1:
6100  CH2IpdvRange = 0.1
6101 #
6102  try:
6103  HoldOff = float(eval(HoldOffentry.get()))
6104  if HoldOff < 0:
6105  HoldOff = 0
6106  HoldOffentry.delete(0,END)
6107  HoldOffentry.insert(0, HoldOff)
6108  except:
6109  HoldOffentry.delete(0,END)
6110  HoldOffentry.insert(0, HoldOff)
6111 #
6112  try:
6113  HozPoss = float(eval(HozPossentry.get()))
6114  except:
6115  HozPossentry.delete(0,END)
6116  HozPossentry.insert(0, HozPoss)
6117 #
6118  hldn = int(HoldOff * SAMPLErate/1000 )
6119  hozpos = int(HozPoss * SAMPLErate/1000 )
6120  if hozpos < 0:
6121  hozpos = 0
6122  # drawing the traces
6123  if TRACEsize == 0: # If no trace, skip rest of this routine
6124  T1Vline = [] # Trace line channel A V
6125  T2Vline = [] # Trace line channel B V
6126  T1Iline = []
6127  T2Iline = []
6128  TMAVline = [] # V Trace line Mux channel A
6129  TMBVline = [] # V Trace line Mux channel B
6130  TMCVline = [] # V Trace line Mux channel C
6131  TMDVline = [] # V Trace line Mux channel D
6132  Tmathline = [] # math trce line
6133  return()
6134 
6135  # set and/or corrected for in range
6136  if TgInput.get() > 0 or ChopTrig.get() > 0:
6137  SCmin = int(-1 * TRIGGERsample)
6138  SCmax = int(TRACEsize - TRIGGERsample - 0)
6139  else:
6140  SCmin = 0 # hldn
6141  SCmax = TRACEsize - 1
6142  if SCstart < SCmin: # No reading before start of array
6143  SCstart = SCmin
6144  if SCstart > SCmax: # No reading after end of array
6145  SCstart = SCmax
6146 
6147  # Make Trace lines etc.
6148 
6149  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
6150  Yconv2 = float(GRH/10.0) / CH2pdvRange
6151  YIconv1 = float(GRH/10.0) / CH1IpdvRange
6152  YIconv2 = float(GRH/10.0) / CH2IpdvRange
6153  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
6154  Xconv2 = float(GRW/10.0) / CH2pdvRange
6155  XIconv1 = float(GRW/10.0) / CH1IpdvRange
6156  XIconv2 = float(GRW/10.0) / CH2IpdvRange
6157  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6158  try:
6159  CHMApdvRange = float(eval(CHB_Asb.get()))
6160  except:
6161  CHB_Asb.delete(0,END)
6162  CHB_Asb.insert(0, CHMApdvRange)
6163  try:
6164  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6165  except:
6166  CHB_Bsb.delete(0,END)
6167  CHB_Bsb.insert(0, CHMBpdvRange)
6168  try:
6169  CHMCpdvRange = float(eval(CHB_Csb.get()))
6170  except:
6171  CHB_Csb.delete(0,END)
6172  CHB_Csb.insert(0, CHMCpdvRange)
6173  try:
6174  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6175  except:
6176  CHB_Dsb.delete(0,END)
6177  CHB_Dsb.insert(0, CHMDpdvRange)
6178  YconvMA = float(GRH/10.0) / CHMApdvRange
6179  YconvMB = float(GRH/10.0) / CHMBpdvRange
6180  YconvMC = float(GRH/10.0) / CHMCpdvRange
6181  YconvMD = float(GRH/10.0) / CHMDpdvRange
6182  try:
6183  CHBAOffset = float(eval(CHB_APosEntry.get()))
6184  except:
6185  CHB_APosEntry.delete(0,END)
6186  CHB_APosEntry.insert(0, CHBAOffset)
6187  try:
6188  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6189  except:
6190  CHB_BPosEntry.delete(0,END)
6191  CHB_BPosEntry.insert(0, CHBBOffset)
6192  try:
6193  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6194  except:
6195  CHB_CPosEntry.delete(0,END)
6196  CHB_CPosEntry.insert(0, CHBCOffset)
6197  try:
6198  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6199  except:
6200  CHB_DPosEntry.delete(0,END)
6201  CHB_DPosEntry.insert(0, CHBDOffset)
6202  if MathAxis == "V-A":
6203  YconvM = Yconv1
6204  CHMOffset = CHAOffset
6205  elif MathAxis == "V-B":
6206  YconvM = Yconv2
6207  CHMOffset = CHBOffset
6208  elif MathAxis == "I-A":
6209  YconvM = YIconv1
6210  CHMOffset = CHAIOffset
6211  elif MathAxis == "I-B":
6212  YconvM = YIconv2
6213  CHMOffset = CHBIOffset
6214  else:
6215  YconvM = Yconv1
6216  CHMOffset = CHAOffset
6217 # include ploting X and Y math formulas vs time
6218  if MathYAxis == "V-A":
6219  YconvMxy = Yconv1
6220  CHMYOffset = CHAOffset
6221  elif MathYAxis == "V-B":
6222  YconvMxy = Yconv2
6223  CHMYOffset = CHBOffset
6224  elif MathYAxis == "I-A":
6225  YconvMxy = YIconv1
6226  CHMYOffset = CHAIOffset
6227  elif MathYAxis == "I-B":
6228  YconvMxy = YIconv2
6229  CHMYOffset = CHBIOffset
6230  else:
6231  YconvMxy = Yconv1
6232  CHMYOffset = CHAOffset
6233 #
6234  if MathXAxis == "V-A":
6235  XconvMxy = Yconv1
6236  CHMXOffset = CHAOffset
6237  elif MathXAxis == "V-B":
6238  XconvMxy = Yconv2
6239  CHMXOffset = CHBOffset
6240  elif MathXAxis == "I-A":
6241  XconvMxy = YIconv1
6242  CHMXOffset = CHAIOffset
6243  elif MathXAxis == "I-B":
6244  XconvMxy = YIconv2
6245  CHMXOffset = CHBIOffset
6246  else:
6247  XconvMxy = Yconv1
6248  CHMXOffset = CHAOffset
6249 #
6250  c1 = GRH / 2.0 + Y0T # fixed correction channel A
6251  c2 = GRH / 2.0 + Y0T # fixed correction channel B
6252 
6253  if First_Slow_sweep == 1:
6254  TRACEsize = len(VBuffA)
6255  DISsamples = GRW
6256  D0line = []
6257  D1line = []
6258  D2line = []
6259  D3line = []
6260  Dconv = float(GRH/10.0) # pixels per Div
6261  else:
6262  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
6263  T1Vline = [] # V Trace line channel A
6264  T2Vline = [] # V Trace line channel B
6265  T1Iline = [] # I Trace line channel A
6266  T2Iline = [] # I Trace line channel B
6267  TMAVline = [] # V Trace line Mux channel A
6268  TMBVline = [] # V Trace line Mux channel B
6269  TMCVline = [] # V Trace line Mux channel C
6270  TMDVline = [] # V Trace line Mux channel D
6271  Tmathline = [] # math trce line
6272  TMXline = [] # X math Trace line
6273  TMYline = [] # Y math Trace line
6274  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
6275  return
6276  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6277  if t < 0:
6278  t = 0
6279  x = 0 # Horizontal screen pixel
6280 #
6281  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6282  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
6283  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6284  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
6285  DvY1 = DvY2 = DiY1 = DiY2 = 0
6286 #
6287  if (DISsamples <= GRW):
6288  Xstep = GRW / DISsamples
6289  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
6290  xa = int((Xstep/-2.5) - (Xstep*DX))
6291  else:
6292  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
6293  x = 0 - int(Xstep*DX)
6294  Tstep = 1
6295  x1 = 0 # x position of trace line
6296  xa1 = 0
6297  y1 = 0.0 # y position of trace line
6298  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6299  ytemp = IBuffA[t]
6300  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6301  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6302  if MuxScreenStatus.get() == 1:
6303  if len(VBuffMA) > 4:
6304  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6305  if len(VBuffMB) > 4:
6306  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6307  if len(VBuffMC) > 4:
6308  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6309  if len(VBuffMD) > 4:
6310  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6311  ytemp = IBuffB[t]
6312  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6313  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
6314  if TgInput.get() == 0:
6315  Xlimit = GRW
6316  else:
6317  Xlimit = GRW+Xstep
6318  while x <= Xlimit:
6319  if t < TRACEsize:
6320  xa1 = xa + X0L
6321  x1 = x + X0L
6322  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6323  ytemp = IBuffA[t]
6324  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6325 
6326  if y1 < Ymin: # clip waveform if going off grid
6327  y1 = Ymin
6328  if y1 > Ymax:
6329  y1 = Ymax
6330  if yi1 < Ymin:
6331  yi1 = Ymin
6332  if yi1 > Ymax:
6333  yi1 = Ymax
6334  if ShowC1_V.get() == 1 :
6335  if ZOHold.get() == 1:
6336  T1Vline.append(int(xa1))
6337  T1Vline.append(int(ypv1))
6338  T1Vline.append(int(xa1))
6339  T1Vline.append(int(y1))
6340  else:
6341  T1Vline.append(int(xa1))
6342  T1Vline.append(int(y1))
6343  DvY1 = ypv1 - y1
6344  ypv1 = y1
6345  if ShowC1_I.get() == 1:
6346  if ZOHold.get() == 1:
6347  T1Iline.append(int(xa1))
6348  T1Iline.append(int(ypi1))
6349  T1Iline.append(int(xa1))
6350  T1Iline.append(int(yi1))
6351  else:
6352  T1Iline.append(int(xa1))
6353  T1Iline.append(int(yi1))
6354  DiY1 = ypi1 - yi1
6355  ypi1 = yi1
6356  if ShowC2_V.get() == 1:
6357  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6358  if y1 < Ymin: # clip waveform if going off grid
6359  y1 = Ymin
6360  if y1 > Ymax:
6361  y1 = Ymax
6362  if ZOHold.get() == 1:
6363  T2Vline.append(int(x1))
6364  T2Vline.append(int(ypv2))
6365  T2Vline.append(int(x1))
6366  T2Vline.append(int(y1))
6367  else:
6368  T2Vline.append(int(x1))
6369  T2Vline.append(int(y1))
6370  DvY2 = ypv2 - y1
6371  ypv2 = y1
6372  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
6373  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6374  if y1 < Ymin: # clip waveform if going off grid
6375  y1 = Ymin
6376  if y1 > Ymax:
6377  y1 = Ymax
6378  if ZOHold.get() == 1:
6379  TMAVline.append(int(x1))
6380  TMAVline.append(int(ypvma))
6381  TMAVline.append(int(x1))
6382  TMAVline.append(int(y1))
6383  else:
6384  TMAVline.append(int(x1))
6385  TMAVline.append(int(y1))
6386  ypvma = y1
6387  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6388  Xfine = MouseX - X0L - x
6389  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
6390  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
6391  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6392  if y1 < Ymin: # clip waveform if going off grid
6393  y1 = Ymin
6394  if y1 > Ymax:
6395  y1 = Ymax
6396  if ZOHold.get() == 1:
6397  TMBVline.append(int(x1))
6398  TMBVline.append(int(ypvmb))
6399  TMBVline.append(int(x1))
6400  TMBVline.append(int(y1))
6401  else:
6402  TMBVline.append(int(x1))
6403  TMBVline.append(int(y1))
6404  ypvmb = y1
6405  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6406  Xfine = MouseX - X0L - x
6407  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
6408  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
6409  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6410  if y1 < Ymin: # clip waveform if going off grid
6411  y1 = Ymin
6412  if y1 > Ymax:
6413  y1 = Ymax
6414  if ZOHold.get() == 1:
6415  TMCVline.append(int(x1))
6416  TMCVline.append(int(ypvmc))
6417  TMCVline.append(int(x1))
6418  TMCVline.append(int(y1))
6419  else:
6420  TMCVline.append(int(x1))
6421  TMCVline.append(int(y1))
6422  ypvmc = y1
6423  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6424  Xfine = MouseX - X0L - x
6425  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
6426  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
6427  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6428  if y1 < Ymin: # clip waveform if going off grid
6429  y1 = Ymin
6430  if y1 > Ymax:
6431  y1 = Ymax
6432  if ZOHold.get() == 1:
6433  TMDVline.append(int(x1))
6434  TMDVline.append(int(ypvmd))
6435  TMDVline.append(int(x1))
6436  TMDVline.append(int(y1))
6437  else:
6438  TMDVline.append(int(x1))
6439  TMDVline.append(int(y1))
6440  ypvmd = y1
6441  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6442  Xfine = MouseX - X0L - x
6443  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
6444  if ShowC2_I.get() == 1:
6445  ytemp = IBuffB[t]
6446  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6447  if yi1 < Ymin:
6448  yi1 = Ymin
6449  if yi1 > Ymax:
6450  yi1 = Ymax
6451  if (ZOHold.get() == 1):
6452  T2Iline.append(int(x1))
6453  T2Iline.append(int(ypi2))
6454  T2Iline.append(int(x1))
6455  T2Iline.append(int(yi1))
6456  else:
6457  T2Iline.append(int(x1))
6458  T2Iline.append(int(yi1))
6459  DiY2 = ypi2 - yi1
6460  ypi2 = yi1
6461  if MathTrace.get() > 0:
6462  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6463  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6464 
6465  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6466  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6467 
6468  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6469  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6470 
6471  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6472  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6473  ytemp = YIconv1 * (Ypower - CHAIOffset)
6474  y1 = int(c1 - ytemp)
6475 
6476  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6477  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6478  ytemp = YIconv2 * (Ypower - CHBIOffset)
6479  y1 = int(c2 - ytemp)
6480 
6481  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6482  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6483  ytemp = YIconv1 * (Yohms - CHAIOffset)
6484  y1 = int(c1 - ytemp)
6485 
6486  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6487  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6488  ytemp = YIconv2 * (Yohms - CHBIOffset)
6489  y1 = int(c2 - ytemp)
6490 
6491  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6492  Ydif = (IBuffA[t] - IBuffB[t])# in mA
6493  ytemp = YIconv1 * (Ydif - CHAIOffset)
6494  y1 = int(c2 - ytemp)
6495 
6496  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6497  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6498  ytemp = YIconv2 * (Ydif - CHBIOffset)
6499  y1 = int(c2 - ytemp)
6500 
6501  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6502  try:
6503  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6504  except:
6505  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6506 
6507  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6508  try:
6509  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6510  except:
6511  Y1 = (IBuffB[t] / 0.000001)
6512  ytemp = YIconv2 * (Y1 - CHBIOffset)
6513  y1 = int(c2 - ytemp)
6514 
6515  elif MathTrace.get() == 12: # plot from equation string
6516  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6517  try:
6518  MathResult = eval(MathString)
6519  MathResult = MathResult - CHMOffset
6520  y1 = int(c1 - YconvM * MathResult)
6521  except:
6522  RUNstatus.set(0)
6523  x = Xlimit + 1 # exit loop
6524 
6525  if y1 < Ymin: # clip waveform if going off grid
6526  y1 = Ymin
6527  if y1 > Ymax:
6528  y1 = Ymax
6529  if ZOHold.get() == 1: # connet the dots with stair step
6530  Tmathline.append(int(x1))
6531  Tmathline.append(int(ypm))
6532  Tmathline.append(int(x1))
6533  Tmathline.append(int(y1))
6534  else: # connet the dots with single line
6535  Tmathline.append(int(x1))
6536  Tmathline.append(int(y1))
6537  ypm = y1
6538  if Show_MathX.get() > 0:
6539  try:
6540  MathResult = eval(MathXString)
6541  MathResult = MathResult - CHMXOffset
6542  y1 = int(c1 - XconvMxy * MathResult)
6543  except:
6544  RUNstatus.set(0)
6545  x = Xlimit + 1 # exit loop
6546 
6547  if y1 < Ymin: # clip waveform if going off grid
6548  y1 = Ymin
6549  if y1 > Ymax:
6550  y1 = Ymax
6551  if ZOHold.get() == 1: # connet the dots with stair step
6552  TMXline.append(int(x1))
6553  TMXline.append(int(ypmx))
6554  TMXline.append(int(x1))
6555  TMXline.append(int(y1))
6556  else: # connet the dots with single line
6557  TMXline.append(int(x1))
6558  TMXline.append(int(y1))
6559  ypmx = y1
6560  if Show_MathY.get() > 0:
6561  try:
6562  MathResult = eval(MathYString)
6563  MathResult = MathResult - CHMYOffset
6564  y1 = int(c1 - YconvMxy * MathResult)
6565  except:
6566  RUNstatus.set(0)
6567  x = Xlimit + 1 # exit loop
6568 
6569  if y1 < Ymin: # clip waveform if going off grid
6570  y1 = Ymin
6571  if y1 > Ymax:
6572  y1 = Ymax
6573  if ZOHold.get() == 1: # connet the dots with stair step
6574  TMYline.append(int(x1))
6575  TMYline.append(int(ypmy))
6576  TMYline.append(int(x1))
6577  TMYline.append(int(y1))
6578  else: # connet the dots with single line
6579  TMYline.append(int(x1))
6580  TMYline.append(int(y1))
6581  ypmy = y1
6582  if D0.get() == 0:
6583  yd = int(c1 - (( DBuff0[t]*0.9 - 5 ) * Dconv))
6584  D0line.append(int(x1))
6585  D0line.append(yd)
6586  if D1.get() == 0:
6587  yd = int(c1 - (( DBuff1[t]*0.9 - 4 ) * Dconv))
6588  D1line.append(int(x1))
6589  D1line.append(yd)
6590  if D2.get() == 0:
6591  yd = int(c1 - (( DBuff2[t]*0.9 - 3 ) * Dconv))
6592  D2line.append(int(x1))
6593  D2line.append(yd)
6594  if D3.get() == 0:
6595  yd = int(c1 - (( DBuff3[t]*0.9 - 2 ) * Dconv))
6596  D3line.append(int(x1))
6597  D3line.append(yd)
6598 
6599  # remember trace verticle pixel at X mouse location
6600  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
6601  Xfine = MouseX - X0L - x
6602  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
6603  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
6604  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
6605  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
6606  t = int(t + Tstep)
6607  x = x + Xstep
6608  xa = xa + Xstep
6609 
6610  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
6611  Xstep = 1
6612  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
6613  x1 = 0.0 # x position of trace line
6614  ylo = 0.0 # ymin position of trace 1 line
6615  yhi = 0.0 # ymax position of trace 1 line
6616 
6617  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6618  if t > len(VBuffA)-1:
6619  t = 0
6620  if t < 0:
6621  t = 0
6622  x = 0 # Horizontal screen pixel
6623  ft = t # time point with fractions
6624  while (x <= GRW):
6625  if (t < TRACEsize):
6626  if (t >= len(VBuffA)):
6627  t = len(VBuffA)-2
6628  x = GRW
6629  x1 = x + X0L
6630  ylo = VBuffA[t] - CHAOffset
6631  ilo = IBuffA[t] - CHAIOffset
6632  yhi = ylo
6633  ihi = ilo
6634  n = t
6635  while n < (t + Tstep) and n < TRACEsize:
6636  if ( ShowC1_V.get() == 1 ):
6637  v = VBuffA[t] - CHAOffset
6638  if v < ylo:
6639  ylo = v
6640  if v > yhi:
6641  yhi = v
6642  if ( ShowC1_I.get() == 1 ):
6643  i = IBuffA[t] - CHAIOffset
6644  if i < ilo:
6645  ilo = i
6646  if i > ihi:
6647  ihi = i
6648  n = n + 1
6649  if ( ShowC1_V.get() == 1 ):
6650  ylo = int(c1 - Yconv1 * ylo)
6651  yhi = int(c1 - Yconv1 * yhi)
6652  if (ylo < Ymin):
6653  ylo = Ymin
6654  if (ylo > Ymax):
6655  ylo = Ymax
6656  if (yhi < Ymin):
6657  yhi = Ymin
6658  if (yhi > Ymax):
6659  yhi = Ymax
6660  T1Vline.append(int(x1))
6661  T1Vline.append(int(ylo))
6662  T1Vline.append(int(x1))
6663  T1Vline.append(int(yhi))
6664  ypv1 = ylo
6665  if ( ShowC1_I.get() == 1 ):
6666  ilo = int(c1 - YIconv1 * ilo)
6667  ihi = int(c1 - YIconv1 * ihi)
6668  if (ilo < Ymin):
6669  ilo = Ymin
6670  if (ilo > Ymax):
6671  ilo = Ymax
6672  if (ihi < Ymin):
6673  ihi = Ymin
6674  if (ihi > Ymax):
6675  ihi = Ymax
6676  T1Iline.append(int(x1))
6677  T1Iline.append(int(ilo))
6678  T1Iline.append(int(x1))
6679  T1Iline.append(int(ihi))
6680  ypi1 = ilo
6681  ylo = VBuffB[t] - CHBOffset
6682  ilo = IBuffB[t] - CHBIOffset
6683  yhi = ylo
6684  ihi = ilo
6685  n = t
6686  if MuxScreenStatus.get() == 0:
6687  while n < (t + Tstep) and n < TRACEsize:
6688  if ( ShowC2_V.get() == 1 ):
6689  v = VBuffB[t] - CHBOffset
6690  if v < ylo:
6691  ylo = v
6692  if v > yhi:
6693  yhi = v
6694  if ( ShowC2_I.get() == 1 ):
6695  i = IBuffB[t] - CHBIOffset
6696  if i < ilo:
6697  ilo = i
6698  if i > ihi:
6699  ihi = i
6700  n = n + 1
6701  if ( ShowC2_V.get() == 1 ):
6702  ylo = int(c2 - Yconv2 * ylo)
6703  yhi = int(c2 - Yconv2 * yhi)
6704  if (ylo < Ymin):
6705  ylo = Ymin
6706  if (ylo > Ymax):
6707  ylo = Ymax
6708 
6709  if (yhi < Ymin):
6710  yhi = Ymin
6711  if (yhi > Ymax):
6712  yhi = Ymax
6713  T2Vline.append(int(x1))
6714  T2Vline.append(int(ylo))
6715  T2Vline.append(int(x1))
6716  T2Vline.append(int(yhi))
6717  ypv2 = ylo
6718  if ( ShowC2_I.get() == 1 ):
6719  ilo = int(c2 - YIconv2 * ilo)
6720  ihi = int(c2 - YIconv2 * ihi)
6721  if (ilo < Ymin):
6722  ilo = Ymin
6723  if (ilo > Ymax):
6724  ilo = Ymax
6725  if (ihi < Ymin):
6726  ihi = Ymin
6727  if (ihi > Ymax):
6728  ihi = Ymax
6729  T2Iline.append(int(x1))
6730  T2Iline.append(int(ilo))
6731  T2Iline.append(int(x1))
6732  T2Iline.append(int(ihi))
6733  ypi2 = ilo
6734  else:
6735  if Show_CBA.get() == 1 and len(VBuffMA)>4:
6736  if t < len(VBuffMA):
6737  ylo = VBuffMA[t] - CHBAOffset
6738  yhi = ylo
6739  n = t
6740  while n < (t + Tstep) and n < len(VBuffMA):
6741  v = VBuffMA[t] - CHBAOffset
6742  if v < ylo:
6743  ylo = v
6744  if v > yhi:
6745  yhi = v
6746  n = n + 1
6747  ylo = int(c2 - YconvMA * ylo)
6748  yhi = int(c2 - YconvMA * yhi)
6749  if (ylo < Ymin):
6750  ylo = Ymin
6751  if (ylo > Ymax):
6752  ylo = Ymax
6753  if (yhi < Ymin):
6754  yhi = Ymin
6755  if (yhi > Ymax):
6756  yhi = Ymax
6757  TMAVline.append(int(x1))
6758  TMAVline.append(int(ylo))
6759  TMAVline.append(int(x1))
6760  TMAVline.append(int(yhi))
6761  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6762  MouseMuxA = ylo
6763  if Show_CBB.get() == 1 and len(VBuffMB)>4:
6764  if t < len(VBuffMB):
6765  ylo = VBuffMB[t] - CHBBOffset
6766  yhi = ylo
6767  n = t
6768  while n < (t + Tstep) and n < len(VBuffMB):
6769  v = VBuffMB[t] - CHBBOffset
6770  if v < ylo:
6771  ylo = v
6772  if v > yhi:
6773  yhi = v
6774  n = n + 1
6775  ylo = int(c2 - YconvMB * ylo)
6776  yhi = int(c2 - YconvMB * yhi)
6777  if (ylo < Ymin):
6778  ylo = Ymin
6779  if (ylo > Ymax):
6780  ylo = Ymax
6781  if (yhi < Ymin):
6782  yhi = Ymin
6783  if (yhi > Ymax):
6784  yhi = Ymax
6785  TMBVline.append(int(x1))
6786  TMBVline.append(int(ylo))
6787  TMBVline.append(int(x1))
6788  TMBVline.append(int(yhi))
6789  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6790  MouseMuxB = ylo
6791  if Show_CBC.get() == 1 and len(VBuffMC)>4:
6792  if t < len(VBuffMC):
6793  ylo = VBuffMC[t] - CHBCOffset
6794  yhi = ylo
6795  n = t
6796  while n < (t + Tstep) and n < len(VBuffMC):
6797  v = VBuffMC[t] - CHBCOffset
6798  if v < ylo:
6799  ylo = v
6800  if v > yhi:
6801  yhi = v
6802  n = n + 1
6803  ylo = int(c2 - YconvMC * ylo)
6804  yhi = int(c2 - YconvMC * yhi)
6805  if (ylo < Ymin):
6806  ylo = Ymin
6807  if (ylo > Ymax):
6808  ylo = Ymax
6809  if (yhi < Ymin):
6810  yhi = Ymin
6811  if (yhi > Ymax):
6812  yhi = Ymax
6813  TMCVline.append(int(x1))
6814  TMCVline.append(int(ylo))
6815  TMCVline.append(int(x1))
6816  TMCVline.append(int(yhi))
6817  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6818  MouseMuxC = ylo
6819  if Show_CBD.get() == 1 and len(VBuffMD)>4:
6820  if t < len(VBuffMD):
6821  ylo = VBuffMD[t] - CHBDOffset
6822  yhi = ylo
6823  n = t
6824  while n < (t + Tstep) and n < len(VBuffMD):
6825  v = VBuffMD[t] - CHBDOffset
6826  if v < ylo:
6827  ylo = v
6828  if v > yhi:
6829  yhi = v
6830  n = n + 1
6831  ylo = int(c2 - YconvMD * ylo)
6832  yhi = int(c2 - YconvMD * yhi)
6833  if (ylo < Ymin):
6834  ylo = Ymin
6835  if (ylo > Ymax):
6836  ylo = Ymax
6837  if (yhi < Ymin):
6838  yhi = Ymin
6839  if (yhi > Ymax):
6840  yhi = Ymax
6841  TMDVline.append(int(x1))
6842  TMDVline.append(int(ylo))
6843  TMDVline.append(int(x1))
6844  TMDVline.append(int(yhi))
6845  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6846  MouseMuxD = ylo
6847  if ( ShowC2_I.get() == 1 ):
6848  while n < (t + Tstep) and n < TRACEsize:
6849  i = IBuffB[t] - CHBIOffset
6850  if i < ilo:
6851  ilo = i
6852  if i > ihi:
6853  ihi = i
6854  n = n + 1
6855  ilo = int(c2 - YIconv2 * ilo)
6856  ihi = int(c2 - YIconv2 * ihi)
6857  if (ilo < Ymin):
6858  ilo = Ymin
6859  if (ilo > Ymax):
6860  ilo = Ymax
6861  if (ihi < Ymin):
6862  ihi = Ymin
6863  if (ihi > Ymax):
6864  ihi = Ymax
6865  T2Iline.append(int(x1))
6866  T2Iline.append(int(ilo))
6867  T2Iline.append(int(x1))
6868  T2Iline.append(int(ihi))
6869  if MathTrace.get() > 0:
6870  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6871  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6872 
6873  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6874  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6875 
6876  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6877  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6878 
6879  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6880  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6881  ytemp = YIconv1 * (Ypower - CHAIOffset)
6882  y1 = int(c1 - ytemp)
6883 
6884  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6885  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6886  ytemp = YIconv2 * (Ypower - CHBIOffset)
6887  y1 = int(c2 - ytemp)
6888 
6889  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6890  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6891  ytemp = YIconv1 * (Yohms- CHAIOffset)
6892  y1 = int(c1 - ytemp)
6893 
6894  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6895  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6896  ytemp = YIconv2 * (Yohms - CHBIOffset)
6897  y1 = int(c2 - ytemp)
6898 
6899  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6900  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
6901  ytemp = YIconv1 * (Ydif - CHAIOffset)
6902  y1 = int(c2 - ytemp)
6903 
6904  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6905  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6906  ytemp = YIconv2 * (Ydif - CHBIOffset)
6907  y1 = int(c2 - ytemp)
6908 
6909  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6910  try:
6911  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6912  except:
6913  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6914  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6915  try:
6916  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6917  except:
6918  Y1 = (IBuffB[t] / 0.000001)
6919  ytemp = YIconv2 * (Y1 - CHBIOffset)
6920  y1 = int(c2 - ytemp)
6921 
6922  elif MathTrace.get() == 12: # plot from equation string
6923  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6924  try:
6925  MathResult = eval(MathString)
6926  MathResult = MathResult - CHMOffset
6927  y1 = int(c1 - YconvM * MathResult)
6928  except:
6929  RUNstatus.set(0)
6930  x = GRW + 1
6931 
6932  if (y1 < Ymin):
6933  y1 = Ymin
6934  if (y1 > Ymax):
6935  y1 = Ymax
6936  if (ZOHold.get() == 1):
6937  Tmathline.append(int(x1))
6938  Tmathline.append(int(ypm))
6939  Tmathline.append(int(x1))
6940  Tmathline.append(int(y1))
6941  else:
6942  Tmathline.append(int(x1))
6943  Tmathline.append(int(y1))
6944  ypm = y1
6945  if Show_MathX.get() > 0:
6946  try:
6947  MathResult = eval(MathXString)
6948  MathResult = MathResult - CHMXOffset
6949  y1 = int(c1 - XconvMxy * MathResult)
6950  except:
6951  RUNstatus.set(0)
6952  x = GRW + 1
6953 
6954  if y1 < Ymin: # clip waveform if going off grid
6955  y1 = Ymin
6956  if y1 > Ymax:
6957  y1 = Ymax
6958  if ZOHold.get() == 1: # connet the dots with stair step
6959  TMXline.append(int(x1))
6960  TMXline.append(int(ypmx))
6961  TMXline.append(int(x1))
6962  TMXline.append(int(y1))
6963  else: # connet the dots with single line
6964  TMXline.append(int(x1))
6965  TMXline.append(int(y1))
6966  ypmx = y1
6967  if Show_MathY.get() > 0:
6968  try:
6969  MathResult = eval(MathYString)
6970  MathResult = MathResult - CHMYOffset
6971  y1 = int(c1 - YconvMxy * MathResult)
6972  except:
6973  RUNstatus.set(0)
6974  x = GRW + 1
6975 
6976  if y1 < Ymin: # clip waveform if going off grid
6977  y1 = Ymin
6978  if y1 > Ymax:
6979  y1 = Ymax
6980  if ZOHold.get() == 1: # connet the dots with stair step
6981  TMYline.append(int(x1))
6982  TMYline.append(int(ypmy))
6983  TMYline.append(int(x1))
6984  TMYline.append(int(y1))
6985  else: # connet the dots with single line
6986  TMYline.append(int(x1))
6987  TMYline.append(int(y1))
6988  ypmy = y1
6989  ft = ft + Tstep
6990  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
6991  MouseCAV = ypv1
6992  MouseCAI = ypi1
6993  MouseCBV = ypv2
6994  MouseCBI = ypi2
6995  t = int(ft)
6996  if (t > len(VBuffA)):
6997  t = len(VBuffA)-2
6998  x = GRW
6999  x = x + Xstep
7000 
7001  # Make trigger triangle pointer
7002  Triggerline = [] # Trigger pointer
7003  Triggersymbol = [] # Trigger symbol
7004  if TgInput.get() > 0 or ChopTrig.get() > 0:
7005  if TgInput.get() == 1 or TgInput.get() == 5: # triggering on CA-V
7006  x1 = X0L
7007  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) #
7008  y1 = int(c1 - ytemp)
7009  elif TgInput.get() == 2: # triggering on CA-I
7010  x1 = X0L+GRW
7011  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
7012  elif TgInput.get() == 3: # triggering on CB-V
7013  x1 = X0L
7014  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) #
7015  y1 = int(c2 - ytemp)
7016  elif TgInput.get() == 4: # triggering on CB-I
7017  x1 = X0L+GRW
7018  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
7019  elif ChopTrig.get() == 1: # triggering on Mux A
7020  x1 = X0L
7021  ytemp = YconvMA * (float(TRIGGERlevel)-CHBAOffset) #
7022  y1 = int(c1 - ytemp)
7023  elif ChopTrig.get() == 2: # triggering on Mux B
7024  x1 = X0L
7025  ytemp = YconvMB * (float(TRIGGERlevel)-CHBBOffset) #
7026  y1 = int(c1 - ytemp)
7027  elif ChopTrig.get() == 3: # triggering on Mux A
7028  x1 = X0L
7029  ytemp = YconvMC * (float(TRIGGERlevel)-CHBCOffset) #
7030  y1 = int(c1 - ytemp)
7031  elif ChopTrig.get() == 4: # triggering on Mux A
7032  x1 = X0L
7033  ytemp = YconvMD * (float(TRIGGERlevel)-CHBDOffset) #
7034  y1 = int(c1 - ytemp)
7035  #
7036  if (y1 < Ymin):
7037  y1 = Ymin
7038  if (y1 > Ymax):
7039  y1 = Ymax
7040  Triggerline.append(int(x1-5))
7041  Triggerline.append(int(y1+5))
7042  Triggerline.append(int(x1+5))
7043  Triggerline.append(int(y1))
7044  Triggerline.append(int(x1-5))
7045  Triggerline.append(int(y1-5))
7046  Triggerline.append(int(x1-5))
7047  Triggerline.append(int(y1+5))
7048  x1 = X0L + (GRW/2)
7049  if TgEdge.get() == 0: # draw rising edge symbol
7050  y1 = -3
7051  y2 = -13
7052  else:
7053  y1 = -13
7054  y2 = -3
7055  Triggersymbol.append(int(x1-10))
7056  Triggersymbol.append(int(Ymin+y1))
7057  Triggersymbol.append(int(x1))
7058  Triggersymbol.append(int(Ymin+y1))
7059  Triggersymbol.append(int(x1))
7060  Triggersymbol.append(int(Ymin+y2))
7061  Triggersymbol.append(int(x1+10))
7062  Triggersymbol.append(int(Ymin+y2))
7063 
7065  global VBuffA, VBuffB, IBuffA, IBuffB
7066  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
7067  global XYlineVA, XYlineVB, XYlineIA, XYlineIB, XYlineM, XYlineMX, XYlineMY
7068  global MathXString, MathYString, MathAxis, MathXAxis, MathYAxis
7069  global HoldOff, HoldOffentry
7070  global X0LXY, Y0TXY, GRWXY, GRHXY
7071  global YminXY, YmaxXY, XminXY, XmaxXY
7072  global SHOWsamples, ZOHold, AWGBMode
7073  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
7074  global TRACES, TRACESread, RUNstatus
7075  global Xsignal, YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
7076  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
7077  global TMpdiv # Array with time / div values in ms
7078  global TMsb # Time per div spin box variable
7079  global TIMEdiv # current spin box value
7080  global SAMPLErate
7081  global SCstart, MathString
7082  global TRIGGERsample, TRACEsize, DX
7083  global TRIGGERlevel, TRIGGERentry, AutoLevel
7084  global InOffA, InGainA, InOffB, InGainB
7085  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
7086  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
7087  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7088  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
7089  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
7090  global HozPoss, HozPossentry
7091 
7092  # Set the TRACEsize variable
7093  if len(VBuffA) < 100:
7094  return
7095  TRACEsize = SHOWsamples # Set the trace length
7096  SCstart = 0
7097  yloVA = yloVB = yloIA = yloIB = yloM = yloMX = yloMY = 0.0
7098  xlo = 0.0
7099  # get the vertical ranges
7100  try:
7101  CH1pdvRange = float(eval(CHAsbxy.get()))
7102  except:
7103  CHAsbxy.delete(0,END)
7104  CHAsbxy.insert(0, CH1pdvRange)
7105  try:
7106  CH2pdvRange = float(eval(CHBsbxy.get()))
7107  except:
7108  CHBsbxy.delete(0,END)
7109  CHBsbxy.insert(0, CH2pdvRange)
7110  try:
7111  CH1IpdvRange = float(eval(CHAIsbxy.get()))
7112  except:
7113  CHAIsbxy.delete(0,END)
7114  CHAIsbxy.insert(0, CH1IpdvRange)
7115  try:
7116  CH2IpdvRange = float(eval(CHBIsbxy.get()))
7117  except:
7118  CHBIsbxy.delete(0,END)
7119  CHBIsbxy.insert(0, CH2IpdvRange)
7120  # get the vertical offsets
7121  try:
7122  CHAOffset = float(eval(CHAVPosEntryxy.get()))
7123  except:
7124  CHAVPosEntryxy.delete(0,END)
7125  CHAVPosEntryxy.insert(0, CHAOffset)
7126  try:
7127  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
7128  except:
7129  CHAIPosEntryxy.delete(0,END)
7130  CHAIPosEntryxy.insert(0, CHAIOffset)
7131  try:
7132  CHBOffset = float(eval(CHBVPosEntryxy.get()))
7133  except:
7134  CHBVPosEntry.delete(0,END)
7135  CHBVPosEntry.insert(0, CHBOffset)
7136  try:
7137  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
7138  except:
7139  CHBIPosEntryxy.delete(0,END)
7140  CHBIPosEntryxy.insert(0, CHBIOffset)
7141  # prevent divide by zero error
7142  if CH1pdvRange < 0.001:
7143  CH1pdvRange = 0.001
7144  if CH2pdvRange < 0.001:
7145  CH2pdvRange = 0.001
7146  if CH1IpdvRange < 0.1:
7147  CH1IpdvRange = 0.1
7148  if CH2IpdvRange < 0.1:
7149  CH2IpdvRange = 0.1
7150  #
7151  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
7152  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
7153  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
7154  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
7155  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
7156  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
7157  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
7158  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
7159 
7160  if MathAxis == "V-A":
7161  YconvM = Yconv1
7162  CHMOffset = CHAOffset
7163  elif MathAxis == "V-B":
7164  YconvM = Yconv2
7165  CHMOffset = CHBOffset
7166  elif MathAxis == "I-A":
7167  YconvM = YIconv1
7168  CHMOffset = CHAIOffset
7169  elif MathAxis == "I-B":
7170  YconvM = YIconv2
7171  CHMOffset = CHBIOffset
7172  else:
7173  YconvM = Yconv1
7174  CHMYOffset = CHAOffset
7175  if MathYAxis == "V-A":
7176  YconvMy = Yconv1
7177  CHMYOffset = CHAOffset
7178  elif MathYAxis == "V-B":
7179  YconvMy = Yconv2
7180  CHMYOffset = CHBOffset
7181  elif MathYAxis == "I-A":
7182  YconvMy = YIconv1
7183  CHMYOffset = CHAIOffset
7184  elif MathYAxis == "I-B":
7185  YconvMy = YIconv2
7186  CHMYOffset = CHBIOffset
7187  else:
7188  YconvMy = Yconv1
7189  CHMYOffset = CHAOffset
7190  if MathXAxis == "V-A":
7191  XconvMxy = Xconv1
7192  CHMXOffset = CHAOffset
7193  YconvMx = Yconv1
7194  elif MathXAxis == "V-B":
7195  XconvMxy = Xconv2
7196  CHMXOffset = CHBOffset
7197  YconvMx = Yconv2
7198  elif MathXAxis == "I-A":
7199  XconvMxy = XIconv1
7200  CHMXOffset = CHAIOffset
7201  YconvMx = YIconv1
7202  elif MathXAxis == "I-B":
7203  XconvMxy = XIconv2
7204  CHMXOffset = CHBIOffset
7205  YconvMx = YIconv2
7206  else:
7207  XconvMxy = Xconv1
7208  CHMXOffset = CHAOffset
7209  YconvMx = Yconv1
7210  # draw an X/Y plot
7211  XYlineVA = [] # XY Trace lines
7212  XYlineVB = []
7213  XYlineIA = []
7214  XYlineIB = []
7215  XYlineM = []
7216  XYlineMX = []
7217  XYlineMY = []
7218  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
7219  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
7220  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7221  while (t < TRACEsize):
7222  # calculate X axis points
7223  if Xsignal.get() == 1: # CVA
7224  xlo = VBuffA[t] - CHAOffset
7225  xlo = int(c2 + Xconv1 * xlo)
7226  elif Xsignal.get() == 3: # CVB
7227  xlo = VBuffB[t] - CHBOffset
7228  xlo = int(c2 + Xconv2 * xlo)
7229  elif Xsignal.get() == 2: # CAI
7230  xlo = (IBuffA[t]) - CHAIOffset
7231  xlo = int(c2 + XIconv1 * xlo)
7232  elif Xsignal.get() == 4: # CBI
7233  xlo = (IBuffB[t]) - CHBIOffset
7234  xlo = int(c2 + XIconv2 * xlo)
7235  elif Xsignal.get() == 5: # Math
7236  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7237  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
7238  xlo = int(c2 + Xconv1 * xlo)
7239  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7240  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
7241  xlo = int(c2 + Xconv2 * xlo)
7242  else:
7243  try:
7244  MathResult = eval(MathXString)
7245  MathResult = MathResult - CHMXOffset
7246  xlo = int(c2 + XconvMxy * MathResult)
7247  except:
7248  RUNstatus.set(0)
7249  if xlo < XminXY: # clip waveform if going off grid
7250  xlo = XminXY
7251  if xlo > XmaxXY:
7252  xlo = XmaxXY
7253  # calculate Y axis points
7254  if YsignalVA.get() == 1: # CAV
7255  yloVA = VBuffA[t] - CHAOffset
7256  yloVA = int(c1 - Yconv1 * yloVA)
7257  if yloVA < YminXY: # clip waveform if going off grid
7258  yloVA = YminXY
7259  if yloVA > YmaxXY:
7260  yloVA = YmaxXY
7261  XYlineVA.append(int(xlo))
7262  XYlineVA.append(int(yloVA))
7263  if YsignalVB.get() == 1: # CBV
7264  yloVB = VBuffB[t] - CHBOffset
7265  yloVB = int(c1 - Yconv2 * yloVB)
7266  if yloVB < YminXY: # clip waveform if going off grid
7267  yloVB = YminXY
7268  if yloVB > YmaxXY:
7269  yloVB = YmaxXY
7270  XYlineVB.append(int(xlo))
7271  XYlineVB.append(int(yloVB))
7272  if YsignalIB.get() == 1: # CBI
7273  yloIB = (IBuffB[t]) - CHBIOffset
7274  yloIB = int(c1 - YIconv2 * yloIB)
7275  if yloIB < YminXY: # clip waveform if going off grid
7276  yloIB = YminXY
7277  if yloIB > YmaxXY:
7278  yloIB = YmaxXY
7279  XYlineIB.append(int(xlo))
7280  XYlineIB.append(int(yloIB))
7281  if YsignalIA.get() == 1: # CAI
7282  yloIA = (IBuffA[t]) - CHAIOffset
7283  yloIA = int(c1 - YIconv1 * yloIA)
7284  if yloIA < YminXY: # clip waveform if going off grid
7285  yloIA = YminXY
7286  if yloIA > YmaxXY:
7287  yloIA = YmaxXY
7288  XYlineIA.append(int(xlo))
7289  XYlineIA.append(int(yloIA))
7290  if YsignalM.get() == 1: # Math
7291  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7292  yloM = VBuffA[t] - VBuffB[t] - CHAOffset
7293  yloM = int(c1 - Yconv1 * yloM)
7294  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7295  yloM = VBuffB[t] - VBuffA[t] - CHBOffset
7296  yloM = int(c1 - Yconv2 * yloM)
7297  else:
7298  try:
7299  MathResult = eval(MathString)
7300  MathResult = MathResult - CHMOffset
7301  yloM = int(c1 - YconvM * MathResult)
7302  except:
7303  RUNstatus.set(0)
7304  if yloM < YminXY: # clip waveform if going off grid
7305  yloM = YminXY
7306  if yloM > YmaxXY:
7307  yloM = YmaxXY
7308  XYlineM.append(int(xlo))
7309  XYlineM.append(int(yloM))
7310  if YsignalMX.get() == 1: # Math-X
7311  try:
7312  MathResult = eval(MathXString)
7313  MathResult = MathResult - CHMXOffset
7314  yloMX = int(c1 - YconvMx * MathResult)
7315  except:
7316  RUNstatus.set(0)
7317  if yloMX < YminXY: # clip waveform if going off grid
7318  yloMX = YminXY
7319  if yloMX > YmaxXY:
7320  yloMX = YmaxXY
7321  XYlineMX.append(int(xlo))
7322  XYlineMX.append(int(yloMX))
7323  if YsignalMY.get() == 1: # Math-Y
7324  try:
7325  MathResult = eval(MathYString)
7326  MathResult = MathResult - CHMYOffset
7327  yloMY = int(c1 - YconvMy * MathResult)
7328  except:
7329  RUNstatus.set(0)
7330  if yloMY < YminXY: # clip waveform if going off grid
7331  yloMY = YminXY
7332  if yloMY > YmaxXY:
7333  yloMY = YmaxXY
7334  XYlineMY.append(int(xlo))
7335  XYlineMY.append(int(yloMY))
7336 
7337  t = int(t + 1)
7338 
7340  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
7341  global TMXline, TMYline
7342  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
7343  global D0line, D1line, D2line, D3line, D0, D1, D2, D3
7344  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
7345  global VBuffA, VBuffB, IBuffA, IBuffB
7346  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
7347  global TMAVline, TMBVline, TMCVline, TMDVline, TMARline, TMBRline, TMCRline, TMDRline
7348  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
7349  global X0L # Left top X value
7350  global Y0T # Left top Y value
7351  global GRW # Screenwidth
7352  global GRH # Screenheight
7353  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
7354  global LabelPlotText, PlotLabelText # plot custom label text flag
7355  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
7356  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
7357  global ShowXCur, ShowYCur, TCursor, VCursor
7358  global SHOWsamples # Number of samples in data record
7359  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Show_MathX, Show_MathY
7360  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
7361  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
7362  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
7363  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
7364  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
7365  global CHAsb # V range spinbox Index for channel 1
7366  global CHBsb # V range spinbox Index for channel 2
7367  global CHAOffset # Position value for channel 1 V
7368  global CHBOffset # Position value for channel 2 V
7369  global CHAIsb # I range spinbox Index for channel 1
7370  global CHBIsb # I range spinbox Index for channel 2
7371  global CHAIOffset # Postion value for channel 1 I
7372  global CHBIOffset # position value for channel 2 I
7373  global TMpdiv # Array with time / div values in ms
7374  global TMsb # Time per div spin box variable
7375  global TIMEdiv, Mulx, DISsamples # current spin box value
7376  global SAMPLErate, contloop, discontloop, HtMulEntry
7377  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
7378  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
7379  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
7380  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
7381  global CANVASwidth, CANVASheight
7382  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
7383  global ScreenTrefresh, SmoothCurves, Is_Triggered
7384  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
7385  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
7386  global InOffA, InGainA, InOffB, InGainB
7387  global CurOffA, CurOffB, CurGainA, CurGainB
7388  # Analog Mux channel measurement variables
7389  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
7390  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
7391  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
7392  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
7393  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
7394  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
7395  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
7396  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
7397  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
7398  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
7399  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
7400  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
7401  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
7402  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7403  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
7404  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
7405  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7406  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7407  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
7408  global D0, D1, D2, D3, D4, D5, D6, D7
7409  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
7410  global HozPoss, HozPossentry, First_Slow_sweep, Roll_Mode
7411  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
7412  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
7413  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
7414  #
7415  Ymin = Y0T # Minimum position of time grid (top)
7416  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
7417 
7418  # DISsamples = (10.0 * TIMEdiv) # grid width in time
7419  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
7420  # get the vertical ranges
7421  try:
7422  CH1pdvRange = float(eval(CHAsb.get()))
7423  except:
7424  CHAsb.delete(0,END)
7425  CHAsb.insert(0, CH1pdvRange)
7426  try:
7427  CH2pdvRange = float(eval(CHBsb.get()))
7428  except:
7429  CHBsb.delete(0,END)
7430  CHBsb.insert(0, CH2pdvRange)
7431  try:
7432  CH1IpdvRange = float(eval(CHAIsb.get()))
7433  except:
7434  CHAIsb.delete(0,END)
7435  CHAIsb.insert(0, CH1IpdvRange)
7436  try:
7437  CH2IpdvRange = float(eval(CHBIsb.get()))
7438  except:
7439  CHBIsb.delete(0,END)
7440  CHBIsb.insert(0, CH2IpdvRange)
7441  # get the vertical offsets
7442  try:
7443  CHAOffset = float(eval(CHAVPosEntry.get()))
7444  except:
7445  CHAVPosEntry.delete(0,END)
7446  CHAVPosEntry.insert(0, CHAOffset)
7447  try:
7448  CHAIOffset = float(eval(CHAIPosEntry.get()))
7449  except:
7450  CHAIPosEntry.delete(0,END)
7451  CHAIPosEntry.insert(0, CHAIOffset)
7452  try:
7453  CHBOffset = float(eval(CHBVPosEntry.get()))
7454  except:
7455  CHBVPosEntry.delete(0,END)
7456  CHBVPosEntry.insert(0, CHBOffset)
7457  try:
7458  CHBIOffset = float(eval(CHBIPosEntry.get()))
7459  except:
7460  CHBIPosEntry.delete(0,END)
7461  CHBIPosEntry.insert(0, CHBIOffset)
7462  try:
7463  HoldOff = float(eval(HoldOffentry.get()))
7464  if HoldOff < 0:
7465  HoldOff = 0
7466  except:
7467  HoldOffentry.delete(0,END)
7468  HoldOffentry.insert(0, HoldOff)
7469  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
7470  try:
7471  Mulx = float(eval(HtMulEntry.get()))
7472  if Mulx < 1:
7473  Mulx = 1
7474  except:
7475  Mulx = 1
7476  if EnableHSsampling > 0:
7477  HtMulEntry.delete(0,END)
7478  HtMulEntry.insert(0, 1)
7479  else:
7480  Mulx = 1
7481  # slide trace left right by HozPoss
7482  try:
7483  HozPoss = float(eval(HozPossentry.get()))
7484  except:
7485  HozPossentry.delete(0,END)
7486  HozPossentry.insert(0, HozPoss)
7487  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7488  try:
7489  CHMApdvRange = float(eval(CHB_Asb.get()))
7490  except:
7491  CHB_Asb.delete(0,END)
7492  CHB_Asb.insert(0, CHMApdvRange)
7493  try:
7494  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7495  except:
7496  CHB_Bsb.delete(0,END)
7497  CHB_Bsb.insert(0, CHMBpdvRange)
7498  try:
7499  CHMCpdvRange = float(eval(CHB_Csb.get()))
7500  except:
7501  CHB_Csb.delete(0,END)
7502  CHB_Csb.insert(0, CHMCpdvRange)
7503  try:
7504  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7505  except:
7506  CHB_Dsb.delete(0,END)
7507  CHB_Dsb.insert(0, CHMDpdvRange)
7508  if CHMApdvRange < 0.001:
7509  CHMApdvRange = 0.001
7510  if CHMBpdvRange < 0.001:
7511  CHMBpdvRange = 0.001
7512  if CHMCpdvRange < 0.001:
7513  CHMCpdvRange = 0.001
7514  if CHMDpdvRange < 0.001:
7515  CHMDpdvRange = 0.001
7516  try:
7517  CHBAOffset = float(eval(CHB_APosEntry.get()))
7518  except:
7519  CHB_APosEntry.delete(0,END)
7520  CHB_APosEntry.insert(0, CHBAOffset)
7521  try:
7522  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7523  except:
7524  CHB_BPosEntry.delete(0,END)
7525  CHB_BPosEntry.insert(0, CHBBOffset)
7526  try:
7527  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7528  except:
7529  CHB_CPosEntry.delete(0,END)
7530  CHB_CPosEntry.insert(0, CHBCOffset)
7531  try:
7532  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7533  except:
7534  CHB_DPosEntry.delete(0,END)
7535  CHB_DPosEntry.insert(0, CHBDOffset)
7536  # prevent divide by zero error
7537  if CH1pdvRange < 0.001:
7538  CH1pdvRange = 0.001
7539  if CH2pdvRange < 0.001:
7540  CH2pdvRange = 0.001
7541  if CH1IpdvRange < 0.1:
7542  CH1IpdvRange = 0.1
7543  if CH2IpdvRange < 0.1:
7544  CH2IpdvRange = 0.1
7545  vt = HoldOff + HozPoss # invert sign and scale to mSec
7546  if ScreenTrefresh.get() == 0:
7547  # Delete all items on the screen
7548  ca.delete(ALL) # remove all items
7549  MarkerNum = 0
7550  # Draw horizontal grid lines
7551  i = 0
7552  x1 = X0L
7553  x2 = X0L + GRW
7554  mg_siz = GRW/10.0
7555  mg_inc = mg_siz/5.0
7556  MathFlag1 = (MathAxis == "V-A" and MathTrace.get() == 12) or (MathXAxis == "V-A" and Show_MathX.get() == 1) or (MathYAxis == "V-A" and Show_MathY.get() == 1)
7557  MathFlag2 = (MathAxis == "V-B" and MathTrace.get() == 12) or (MathXAxis == "V-B" and Show_MathX.get() == 1) or (MathYAxis == "V-B" and Show_MathY.get() == 1)
7558  MathFlag3 = (MathAxis == "I-A" and MathTrace.get() == 12) or (MathXAxis == "I-A" and Show_MathX.get() == 1) or (MathYAxis == "I-A" and Show_MathY.get() == 1)
7559  MathFlag4 = (MathAxis == "I-B" and MathTrace.get() == 12) or (MathXAxis == "I-B" and Show_MathX.get() == 1) or (MathYAxis == "I-B" and Show_MathY.get() == 1)
7560  # vertical scale text labels
7561  RightOffset = FontSize * 3
7562  LeftOffset = int(FontSize/2)
7563  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
7564  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
7565  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
7566  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
7567  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
7568  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
7569  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
7570  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
7571  #
7572  while (i < 11):
7573  y = Y0T + i * GRH/10.0
7574  Dline = [x1,y,x2,y]
7575  if i == 5:
7576  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
7577  k = 0
7578  while (k < 10):
7579  l = 1
7580  while (l < 5):
7581  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
7582  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7583  l = l + 1
7584  k = k + 1
7585  else:
7586  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7587 
7588  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
7589  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7590  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
7591  Vaxis_label = str(round(Vaxis_value,3 ))
7592  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
7593 
7594  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
7595  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
7596  Iaxis_label = str(round(Iaxis_value, 3))
7597  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
7598 
7599  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
7600  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7601  Vaxis_label = str(round(Vaxis_value, 3))
7602  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
7603 
7604  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
7605  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
7606  Iaxis_label = str(round(Iaxis_value, 3))
7607  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
7608  if MuxScreenStatus.get() == 1:
7609  if Show_CBA.get() == 1:
7610  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
7611  Vaxis_label = str(round(Vaxis_value, 3))
7612  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
7613  if Show_CBB.get() == 1:
7614  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
7615  Iaxis_label = str(round(Iaxis_value, 3))
7616  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
7617  if Show_CBC.get() == 1:
7618  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
7619  Iaxis_label = str(round(Iaxis_value, 3))
7620  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
7621  if Show_CBD.get() == 1:
7622  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
7623  Iaxis_label = str(round(Iaxis_value, 3))
7624  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
7625  i = i + 1
7626  # Draw vertical grid lines
7627  i = 0
7628  y1 = Y0T
7629  y2 = Y0T + GRH
7630  mg_siz = GRH/10.0
7631  mg_inc = mg_siz/5.0
7632  vx = TIMEdiv/Mulx
7633  vt = HoldOff/Mulx # invert sign and scale to mSec
7634  # vx = TIMEdiv
7635  while (i < 11):
7636  x = X0L + i * GRW/10.0
7637  Dline = [x,y1,x,y2]
7638  if (i == 5):
7639  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
7640  k = 0
7641  while (k < 10):
7642  l = 1
7643  while (l < 5):
7644  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
7645  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7646  l = l + 1
7647  k = k + 1
7648  #
7649  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7650  if vx >= 1000:
7651  axis_value = ((i * vx)+ vt) / 1000.0
7652  axis_label = ' {0:.1f} '.format(axis_value) + " S"
7653  if vx < 1000 and vx >= 1:
7654  axis_value = (i * vx) + vt
7655  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
7656  if vx < 1:
7657  axis_value = ((i * vx) + vt) * 1000.0
7658  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
7659  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
7660  else:
7661  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7662  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7663  if vx >= 1000:
7664  axis_value = ((i * vx)+ vt) / 1000.0
7665  axis_label = ' {0:.1f} '.format(axis_value) + " S"
7666  if vx < 1000 and vx >= 1:
7667  axis_value = (i * vx) + vt
7668  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
7669  if vx < 1:
7670  axis_value = ((i * vx) + vt) * 1000.0
7671  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
7672  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
7673 
7674  i = i + 1
7675  # Write the trigger line if available
7676  if Roll_Mode.get() == 0: # Don't show trigger indicator when in Roll Mode
7677  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
7678  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
7679  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
7680  if TgInput.get() == 1:
7681  TgLabel = "CA-V"
7682  if TgInput.get() == 2:
7683  TgLabel = "CA-I"
7684  if TgInput.get() == 3:
7685  TgLabel = "CB-V"
7686  if TgInput.get() == 4:
7687  TgLabel = "CB-I"
7688  if TgInput.get() == 5:
7689  TgLabel = "VA or VB"
7690  if TgInput.get() == 6:
7691  TgLabel = "Alternate"
7692  if ChopTrig.get() == 1:
7693  TgLabel = "Mux A"
7694  if ChopTrig.get() == 2:
7695  TgLabel = "Mux B"
7696  if ChopTrig.get() == 3:
7697  TgLabel = "Mux C"
7698  if ChopTrig.get() == 4:
7699  TgLabel = "Mux D"
7700  if Is_Triggered == 1:
7701  TgLabel = TgLabel + " Triggered"
7702  else:
7703  TgLabel = TgLabel + " Not Triggered"
7704  if SingleShot.get() > 0:
7705  TgLabel = TgLabel + " Armed"
7706  x = X0L + (GRW/2) + 12
7707  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
7708  # Draw T - V Cursor lines if required
7709  if MarkerScale.get() == 0:
7710  Yconv1 = float(GRH/10.0) / CH1pdvRange
7711  Yoffset1 = CHAOffset
7712  COLORmarker = COLORtrace1
7713  Units = " V"
7714  if MarkerScale.get() == 1:
7715  MouseY = MouseCAV
7716  Yconv1 = float(GRH/10.0) / CH1pdvRange
7717  Yoffset1 = CHAOffset
7718  COLORmarker = COLORtrace1
7719  Units = " V"
7720  if MarkerScale.get() == 2:
7721  MouseY = MouseCBV
7722  Yconv1 = float(GRH/10.0) / CH2pdvRange
7723  Yoffset1 = CHBOffset
7724  COLORmarker = COLORtrace2
7725  Units = " V"
7726  if MarkerScale.get() == 3:
7727  MouseY = MouseCAI
7728  Yconv1 = float(GRH/10.0) / CH1IpdvRange
7729  Yoffset1 = CHAIOffset
7730  COLORmarker = COLORtrace3
7731  Units = " mA"
7732  if MarkerScale.get() == 4:
7733  MouseY = MouseCBI
7734  Yconv1 = float(GRH/10.0) / CH2IpdvRange
7735  Yoffset1 = CHBIOffset
7736  COLORmarker = COLORtrace4
7737  Units = " mA"
7738  # Analog Mux settings
7739  if MarkerScale.get() == 5:
7740  MouseY = MouseMuxA
7741  Yconv1 = float(GRH/10.0) / CHMApdvRange
7742  Yoffset1 = CHBAOffset
7743  COLORmarker = COLORtrace2
7744  Units = " V"
7745  if MarkerScale.get() == 6:
7746  MouseY = MouseMuxB
7747  Yconv1 = float(GRH/10.0) / CHMBpdvRange
7748  Yoffset1 = CHBBOffset
7749  COLORmarker = COLORtrace6
7750  Units = " V"
7751  if MarkerScale.get() == 7:
7752  MouseY = MouseMuxC
7753  Yconv1 = float(GRH/10.0) / CHMCpdvRange
7754  Yoffset1 = CHBCOffset
7755  COLORmarker = COLORtrace7
7756  Units = " V"
7757  if MarkerScale.get() == 8:
7758  MouseY = MouseMuxD
7759  Yconv1 = float(GRH/10.0) / CHMDpdvRange
7760  Yoffset1 = CHBDOffset
7761  COLORmarker = COLORtrace4
7762  Units = " V"
7763 #
7764  if ShowTCur.get() > 0:
7765  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
7766  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7767  Tpoint = ((TCursor-X0L) * Tstep) + vt
7768  Tpoint = Tpoint/Mulx
7769  if Tpoint >= 1000:
7770  axis_value = Tpoint / 1000.0
7771  V_label = ' {0:.2f} '.format(axis_value) + " S"
7772  if Tpoint < 1000 and Tpoint >= 1:
7773  axis_value = Tpoint
7774  V_label = ' {0:.2f} '.format(axis_value) + " mS"
7775  if Tpoint < 1:
7776  axis_value = Tpoint * 1000.0
7777  V_label = ' {0:.2f} '.format(axis_value) + " uS"
7778  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7779  ca.create_text(TCursor, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
7780  if ShowVCur.get() > 0:
7781  Dline = [X0L, VCursor, X0L+GRW, VCursor]
7782  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
7783  c1 = GRH / 2 + Y0T # fixed Y correction
7784  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
7785  V1String = ' {0:.3f} '.format(-yvolts)
7786  V_label = V1String + Units
7787  ca.create_text(X0L+GRW+2, VCursor, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
7788  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
7789  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
7790  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
7791  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7792  ca.create_oval(MouseX-GridWidth.get(), MouseY-GridWidth.get(), MouseX+GridWidth.get(), MouseY+GridWidth.get(), outline=COLORtrigger, fill=COLORtrigger, width=GridWidth.get())
7793  Tpoint = ((MouseX-X0L) * Tstep) + vt
7794  Tpoint = Tpoint/Mulx
7795  if Tpoint >= 1000:
7796  axis_value = Tpoint / 1000.0
7797  V_label = ' {0:.2f} '.format(axis_value) + " S"
7798  if Tpoint < 1000 and Tpoint >= 1:
7799  axis_value = Tpoint
7800  V_label = ' {0:.2f} '.format(axis_value) + " mS"
7801  if Tpoint < 1:
7802  axis_value = Tpoint * 1000.0
7803  V_label = ' {0:.2f} '.format(axis_value) + " uS"
7804  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7805  ca.create_text(MouseX, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
7806  Dline = [X0L, MouseY, X0L+GRW, MouseY]
7807  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7808  c1 = GRH / 2 + Y0T # fixed Y correction
7809  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7810  V1String = ' {0:.3f} '.format(-yvolts)
7811  V_label = V1String + Units
7812  ca.create_text(X0L+GRW+2, MouseY, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
7813 #
7814  if MeasGateStatus.get() == 1:
7815  LeftGate = X0L + MeasGateLeft / Tstep
7816  RightGate = X0L + MeasGateRight / Tstep
7817  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace5)
7818  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace7)
7819  #
7820  # TString = ' {0:.2f} '.format(Tpoint)
7821  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7822  DT = (MeasGateRight-MeasGateLeft)/Mulx
7823  if DT == 0.0:
7824  DT = 1.0
7825  if DT >= 1000:
7826  axis_value = DT / 1000.0
7827  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
7828  if DT < 1000 and DT >= 1:
7829  axis_value = DT
7830  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
7831  if DT < 1:
7832  axis_value = DT * 1000.0
7833  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
7834  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
7835  DFreq = ' {0:.3f} '.format(1.0/DT)
7836  V_label = " Delta T" + DeltaT
7837  #V_label = V_label + Units
7838  V_label = V_label + ", Freq " + DFreq + " KHz"
7839  # place in upper left unless specified otherwise
7840  x = X0L + 5
7841  y = Y0T + 7
7842  Justify = 'w'
7843  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
7844  x = X0L + GRW - 5
7845  y = Y0T + 7
7846  Justify = 'e'
7847  if MarkerLoc == 'LL' or MarkerLoc == 'll':
7848  x = X0L + 5
7849  y = Y0T + GRH + 7 - (MarkerNum*10)
7850  Justify = 'w'
7851  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
7852  x = X0L + GRW - 5
7853  y = Y0T + GRH + 7
7854  Justify = 'e'
7855  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
7856  #
7857 #
7858  SmoothBool = SmoothCurves.get()
7859  # Write the traces if available
7860  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
7861  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
7862  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
7863  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
7864  if len(T2Vline) > 4: # Write the trace 2 if active
7865  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7866  if len(T2Iline) > 4:
7867  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7868  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
7869  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7870  if len(TMXline) > 4 : # Write X Math tace if active
7871  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7872  if len(TMYline) > 4 : # Write Y Math tace if active
7873  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7874  if MuxScreenStatus.get() == 1:
7875  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
7876  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7877  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
7878  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7879  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
7880  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7881  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
7882  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7883  if ShowRMA.get() == 1 and len(TMARline) > 4:
7884  ca.create_line(TMARline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7885  if ShowRMB.get() == 1 and len(TMBRline) > 4:
7886  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7887  if ShowRMC.get() == 1 and len(TMCRline) > 4:
7888  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7889  if ShowRMD.get() == 1 and len(TMDRline) > 4:
7890  ca.create_line(TMDRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7891  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
7892  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7893  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
7894  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7895  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
7896  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7897  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
7898  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7899  if ShowMath.get() == 1 and len(TMRline) > 4:
7900  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7901  if First_Slow_sweep == 1:
7902  # print(len(D0line),len(D1line), len(D2line), len(D3line))
7903  if D0.get() == 0:
7904  ca.create_line(D0line, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7905  if D1.get() == 0:
7906  ca.create_line(D1line, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7907  if D2.get() == 0:
7908  ca.create_line(D2line, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7909  if D3.get() == 0:
7910  ca.create_line(D3line, fill=COLORzeroline, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7911  # General information on top of the grid
7912  # Sweep information
7913  if session.continuous:
7914  sttxt = "Running Continuous"
7915  else:
7916  sttxt = "Running Discontinuous"
7917  if TRACEmodeTime.get() == 1:
7918  sttxt = sttxt + " Averaging"
7919  if ManualTrigger.get() == 1:
7920  sttxt = "Manual Trigger"
7921  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7922  sttxt = "Stopped"
7923  if ScreenTrefresh.get() == 1:
7924  sttxt = sttxt + " Persistance ON"
7925  # Delete text at bottom of screen
7926  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
7927  for n in de:
7928  ca.delete(n)
7929  # Delete text at top of screen
7930  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
7931  for n in de:
7932  ca.delete(n)
7933  if Roll_Mode.get() == 0:
7934  if LabelPlotText.get() > 0:
7935  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7936  else:
7937  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7938  else:
7939  if LabelPlotText.get() > 0:
7940  txt = PlotLabelText + " Rolling Sweep " + sttxt
7941  else:
7942  txt = "Device ID " + DevID[17:31] + " Rolling Sweep " + sttxt
7943  x = X0L+2
7944  y = 12
7945  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7946  # digital I/O indicators
7947  x2 = X0L + GRW
7948  BoxColor = "#808080" # gray
7949  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
7950  if D0.get() == 0 and D4.get() == 0:
7951  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7952  if Dval[0] == 1:
7953  BoxColor = "#00ff00" # 100% green
7954  elif Dval[0] == 0:
7955  BoxColor = "#ff0000" # 100% red
7956  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7957  else:
7958  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7959  if D1.get() == 0 and D5.get() == 0:
7960  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
7961  if Dval[0] == 1:
7962  BoxColor = "#00ff00" # 100% green
7963  elif Dval[0] == 0:
7964  BoxColor = "#ff0000" # 100% red
7965  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
7966  else:
7967  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
7968  if D2.get() == 0 and D6.get() == 0:
7969  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
7970  if Dval[0] == 1:
7971  BoxColor = "#00ff00" # 100% green
7972  elif Dval[0] == 0:
7973  BoxColor = "#ff0000" # 100% red
7974  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
7975  else:
7976  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
7977  if D3.get() == 0 and D7.get() == 0:
7978  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
7979  if Dval[0] == 1:
7980  BoxColor = "#00ff00" # 100% green
7981  elif Dval[0] == 0:
7982  BoxColor = "#ff0000" # 100% red
7983  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
7984  else:
7985  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
7986  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7987  # Time sweep information and view at information
7988  vx = TIMEdiv/Mulx
7989  if vx >= 1000:
7990  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
7991  if vx < 1000 and vx >= 1:
7992  txt = ' {0:.2f} '.format(vx) + " mS/div"
7993  if vx < 1:
7994  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
7995 
7996  txt = txt + " "
7997  #
7998  txt = txt + "View at "
7999  if abs(vt) >= 1000:
8000  txt = txt + str(int(vt / 1000.0)) + " S "
8001  if abs(vt) < 1000 and abs(vt) >= 1:
8002  txt = txt + str(int(vt)) + " mS "
8003  if abs(vt) < 1:
8004  txt = txt + str(int(vt * 1000.0)) + " uS "
8005  # print period and frequency of displayed channels
8006  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
8007  if ETSDisp.get() > 0:
8008  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
8009  else:
8010  if MeasGateStatus.get() == 1:
8011  if (MeasGateRight-MeasGateLeft) > 0:
8012  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
8013  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
8014  if Endsample <= hldn:
8015  Endsample = hldn + 2
8016  FindRisingEdge(VBuffA[hldn:Endsample],VBuffB[hldn:Endsample])
8017  else:
8018  FindRisingEdge(VBuffA,VBuffB)
8019  if ShowC1_V.get() == 1:
8020  if MeasAHW.get() == 1:
8021  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
8022  if MeasALW.get() == 1:
8023  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
8024  if MeasADCy.get() == 1:
8025  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8026  if MeasAPER.get() == 1:
8027  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
8028  if MeasAFREQ.get() == 1:
8029  txt = txt + " CA Freq = "
8030  ChaF = CHAfreq*Mulx
8031  if ChaF < 1000:
8032  V1String = ' {0:.1f} '.format(ChaF)
8033  txt = txt + str(V1String) + " Hz "
8034  if ChaF > 1000 and ChaF < 1000000:
8035  V1String = ' {0:.1f} '.format(ChaF/1000)
8036  txt = txt + str(V1String) + " KHz "
8037  if ChaF > 1000000:
8038  V1String = ' {0:.1f} '.format(ChaF/1000000)
8039  txt = txt + str(V1String) + " MHz "
8040  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8041  if ShowC2_V.get() == 1:
8042  if MeasBHW.get() == 1:
8043  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
8044  if MeasBLW.get() == 1:
8045  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
8046  if MeasBDCy.get() == 1:
8047  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8048  if MeasBPER.get() == 1:
8049  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
8050  if MeasBFREQ.get() == 1:
8051  txt = txt + " CB Freq = "
8052  ChaF = CHBfreq*Mulx
8053  if ChaF < 1000:
8054  V1String = ' {0:.1f} '.format(ChaF)
8055  txt = txt + str(V1String) + " Hz "
8056  if ChaF > 1000 and ChaF < 1000000:
8057  V1String = ' {0:.1f} '.format(ChaF/1000)
8058  txt = txt + str(V1String) + " KHz "
8059  if ChaF > 1000000:
8060  V1String = ' {0:.1f} '.format(ChaF/1000000)
8061  txt = txt + str(V1String) + " MHz "
8062  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8063  if MuxScreenStatus.get() == 0:
8064  if MeasPhase.get() == 1:
8065  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8066  if MeasDelay.get() == 1:
8067  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8068 
8069  x = X0L
8070  y = Y0T+GRH+int(2.5 *FontSize) # 20
8071  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8072  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
8073  MakeHistogram()
8074  txt = " "
8075  if ShowC1_V.get() == 1:
8076  # Channel A information
8077  if CHA_RC_HP.get() == 1:
8078  txt = "CHA: HP "
8079  else:
8080  txt = "CHA: "
8081  txt = txt + str(CH1pdvRange) + " V/div"
8082  if MeasDCV1.get() == 1:
8083  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8084  if MeasMaxV1.get() == 1:
8085  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8086  if MeasTopV1.get() == 1:
8087  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8088  if MeasMinV1.get() == 1:
8089  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8090  if MeasBaseV1.get() == 1:
8091  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
8092  if MeasMidV1.get() == 1:
8093  MidV1 = (MaxV1+MinV1)/2.0
8094  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8095  if MeasPPV1.get() == 1:
8096  PPV1 = MaxV1-MinV1
8097  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8098  if MeasRMSV1.get() == 1:
8099  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8100  if MeasRMSVA_B.get() == 1:
8101  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
8102  if MeasDiffAB.get() == 1:
8103  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
8104  if MeasUserA.get() == 1:
8105  try:
8106  TempValue = eval(UserAString)
8107  V1String = ' {0:.4f} '.format(TempValue)
8108  except:
8109  V1String = "####"
8110  txt = txt + UserALabel + " = " + V1String
8111  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
8112  txt = "CHA: "
8113  txt = txt + str(CH1IpdvRange) + " mA/div"
8114  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
8115  txt = txt + "CHA: "
8116  txt = txt + str(CH1IpdvRange) + " mA/div"
8117  if ShowC1_I.get() == 1:
8118  if MeasDCI1.get() == 1:
8119  V1String = ' {0:.2f} '.format(DCI1)
8120  txt = txt + " AvgI = " + V1String
8121  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8122  try:
8123  Resvalue = (DCV1/DCI1)*1000
8124  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8125  except:
8126  txt = txt + " Res = OverRange"
8127  if MeasMaxI1.get() == 1:
8128  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8129  if MeasMinI1.get() == 1:
8130  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8131  if MeasMidI1.get() == 1:
8132  MidI1 = (MaxI1+MinI1)/2.0
8133  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8134  if MeasPPI1.get() == 1:
8135  PPI1 = MaxI1-MinI1
8136  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8137  if MeasRMSI1.get() == 1:
8138  txt = txt + " RMS = " + ' {0:.2f} '.format(SI1)
8139 
8140  x = X0L
8141  y = Y0T+GRH+(4*FontSize) # 32
8142  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8143  txt= " "
8144  # Channel B information
8145  if MuxScreenStatus.get() == 1:
8146  txt = "CHB-Mux: "
8147  if Show_CBA.get() > 0:
8148  FindRisingEdge(VBuffA,VBuffMA)
8149  elif Show_CBB.get() > 0:
8150  FindRisingEdge(VBuffA,VBuffMB)
8151  elif Show_CBC.get() > 0:
8152  FindRisingEdge(VBuffA,VBuffMC)
8153  elif Show_CBD.get() > 0:
8154  FindRisingEdge(VBuffA,VBuffMD)
8155  if MeasPhase.get() == 1:
8156  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8157  if MeasDelay.get() == 1:
8158  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8159  if MeasUserB.get() == 1:
8160  try:
8161  TempValue = eval(UserBString)
8162  V1String = ' {0:.4f} '.format(TempValue)
8163  except:
8164  V1String = "####"
8165  txt = txt + UserBLabel + " = " + V1String
8166  if ShowC2_V.get() == 1:
8167  if CHB_RC_HP.get() == 1:
8168  txt = "CHB: HP "
8169  else:
8170  txt = "CHB: "
8171  txt = txt + str(CH2pdvRange) + " V/div"
8172  if MeasDCV2.get() == 1:
8173  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8174  if MeasMaxV2.get() == 1:
8175  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8176  if MeasTopV2.get() == 1:
8177  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8178  if MeasMinV2.get() == 1:
8179  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8180  if MeasBaseV2.get() == 1:
8181  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
8182  if MeasMidV2.get() == 1:
8183  MidV2 = (MaxV2+MinV2)/2.0
8184  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8185  if MeasPPV2.get() == 1:
8186  PPV2 = MaxV2-MinV2
8187  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8188  if MeasRMSV2.get() == 1:
8189  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8190  if MeasDiffBA.get() == 1:
8191  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
8192  if MeasUserB.get() == 1:
8193  try:
8194  TempValue = eval(UserBString)
8195  V1String = ' {0:.4f} '.format(TempValue)
8196  except:
8197  V1String = "####"
8198  txt = txt + UserBLabel + " = " + V1String
8199  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
8200  txt = "CHB: "
8201  txt = txt + str(CH2IpdvRange) + " mA/div"
8202  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
8203  txt = txt + "CHB: "
8204  txt = txt + str(CH2IpdvRange) + " mA/div"
8205  if ShowC2_I.get() == 1:
8206  if MeasDCI2.get() == 1:
8207  V1String = ' {0:.2f} '.format(DCI2)
8208  txt = txt + " AvgI = " + V1String
8209  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8210  try:
8211  Resvalue = (DCV2/DCI2)*1000
8212  R1String = ' {0:.1f} '.format(Resvalue)
8213  txt = txt + " Res = " + R1String
8214  except:
8215  txt = txt + " Res = OverRange"
8216  if MeasMaxI2.get() == 1:
8217  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8218  if MeasMinI2.get() == 1:
8219  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8220  if MeasMidI2.get() == 1:
8221  MidI2 = (MaxI2+MinI2)/2.0
8222  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8223  if MeasPPI2.get() == 1:
8224  PPI2 = MaxI2-MinI2
8225  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8226  if MeasRMSI2.get() == 1:
8227  txt = txt + " RMS = " + ' {0:.2f} '.format(SI2)
8228 
8229  x = X0L
8230  y = Y0T+GRH+int(5.5*FontSize) # 44
8231  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8232 
8234  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY # active trave lines
8235  global Tmathline, TMRline, XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
8236  global X0LXY # Left top X value
8237  global Y0TXY # Left top Y value
8238  global GRWXY # Screenwidth
8239  global GRHXY # Screenheight
8240  global FontSize, LabelPlotText, PlotLabelText
8241  global XYca, MouseX, MouseY, MouseWidget
8242  global ShowXCur, ShowYCur, XCursor, YCursor
8243  global SHOWsamples # Number of samples in data record
8244  global ShowMath, MathUnits, MathXUnits, MathYUnits
8245  global Xsignal, MathAxis, MathXAxis, MathYAxis
8246  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMY, YsignalMX
8247  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
8248  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
8249  global CHAsbxy # spinbox Index for channel 1 V
8250  global CHBsbxy # spinbox Index for channel 2 V
8251  global CHAOffset # Offset value for channel 1 V
8252  global CHBOffset # Offset value for channel 2 V
8253  global CHAIsbxy # spinbox Index for channel 1 I
8254  global CHBIsbxy # spinbox Index for channel 2 I
8255  global CHAIOffset # Offset value for channel 1 I
8256  global CHBIOffset # Offset value for channel 2 I
8257  global TMpdiv # Array with time / div values in ms
8258  global TMsb # Time per div spin box variable
8259  global TIMEdiv # current spin box value
8260  global SAMPLErate
8261  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
8262  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace6, COLORtrace7 # The colors
8263  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
8264  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6, COLORtraceR7
8265  global CANVASwidthXY, CANVASheightXY, COLORXmarker, COLORYmarker
8266  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
8267  global ScreenXYrefresh, SmoothCurves
8268  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
8269  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
8270  global SV1, SI1, SV2, SI2, CHABphase
8271  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
8272  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
8273  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
8274  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
8275  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
8276  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
8277  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
8278  global AWGAShape, AWGBShape
8279  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
8280  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
8281  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
8282  global DacScreenStatus, DigScreenStatus
8283  global D0, D1, D2, D3, D4, D5, D6, D7
8284  global DevID, devx, MarkerNum, MarkerScale
8285  global HozPoss, HozPossentry
8286  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
8287  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
8288  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
8289  #
8290  Ymin = Y0TXY # Minimum position of screen grid (top)
8291  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
8292  RightOffset = FontSize * 3
8293  LeftOffset = int(FontSize/2)
8294  try:
8295  InOffA = float(eval(CHAVOffsetEntry.get()))
8296  except:
8297  CHAVOffsetEntry.delete(0,END)
8298  CHAVOffsetEntry.insert(0, InOffA)
8299  try:
8300  InGainA = float(eval(CHAVGainEntry.get()))
8301  except:
8302  CHAVGainEntry.delete(0,END)
8303  CHAVGainEntry.insert(0, InGainA)
8304  try:
8305  InOffB = float(eval(CHBVOffsetEntry.get()))
8306  except:
8307  CHBVOffsetEntry.delete(0,END)
8308  CHBVOffsetEntry.insert(0, InOffB)
8309  try:
8310  InGainB = float(eval(CHBVGainEntry.get()))
8311  except:
8312  CHBVGainEntry.delete(0,END)
8313  CHBVGainEntry.insert(0, InGainB)
8314 #
8315  try:
8316  CH1pdvRange = float(eval(CHAsbxy.get()))
8317  except:
8318  CHAsbxy.delete(0,END)
8319  CHAsbxy.insert(0, CH1pdvRange)
8320  try:
8321  CH2pdvRange = float(eval(CHBsbxy.get()))
8322  except:
8323  CHBsbxy.delete(0,END)
8324  CHBsbxy.insert(0, CH2pdvRange)
8325  try:
8326  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8327  except:
8328  CHAIsbxy.delete(0,END)
8329  CHAIsbxy.insert(0, CH1IpdvRange)
8330  try:
8331  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8332  except:
8333  CHBIsbxy.delete(0,END)
8334  CHBIsbxy.insert(0, CH2IpdvRange)
8335  # get the vertical offsets
8336  try:
8337  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8338  except:
8339  CHAVPosEntryxy.delete(0,END)
8340  CHAVPosEntryxy.insert(0, CHAOffset)
8341  try:
8342  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8343  except:
8344  CHAIPosEntryxy.delete(0,END)
8345  CHAIPosEntryxy.insert(0, CHAIOffset)
8346  try:
8347  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8348  except:
8349  CHBVPosEntry.delete(0,END)
8350  CHBVPosEntry.insert(0, CHBOffset)
8351  try:
8352  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8353  except:
8354  CHBIPosEntryxy.delete(0,END)
8355  CHBIPosEntryxy.insert(0, CHBIOffset)
8356  # prevent divide by zero error
8357  if CH1pdvRange < 0.001:
8358  CH1pdvRange = 0.001
8359  if CH2pdvRange < 0.001:
8360  CH2pdvRange = 0.001
8361  if CH1IpdvRange < 0.05:
8362  CH1IpdvRange = 0.05
8363  if CH2IpdvRange < 0.05:
8364  CH2IpdvRange = 0.05
8365  # If drawing histograms adjust offset based on range such that bottom grid is zero
8366  if Xsignal.get() == 6:
8367  CHAIOffset = 5 * CH1IpdvRange
8368  if Xsignal.get() == 7:
8369  CHBIOffset = 5 * CH2IpdvRange
8370  if ScreenXYrefresh.get() == 0:
8371  # Delete all items on the screen
8372  MarkerNum = 0
8373  XYca.delete(ALL) # remove all items
8374  # Draw horizontal grid lines
8375  i = 0
8376  x1 = X0LXY
8377  x2 = X0LXY + GRWXY
8378  mg_siz = GRWXY/10.0
8379  mg_inc = mg_siz/5.0
8380  while (i < 11):
8381  y = Y0TXY + i * GRHXY/10.0
8382  Dline = [x1,y,x2,y]
8383  if i == 5:
8384  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8385  k = 0
8386  while (k < 10):
8387  l = 1
8388  while (l < 5):
8389  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8390  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8391  l = l + 1
8392  k = k + 1
8393  else:
8394  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8395  if YsignalIA.get() == 1 or Xsignal.get() == 6:
8396  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8397  Iaxis_label = str(round(Iaxis_value, 3))
8398  XYca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8399  if YsignalIB.get() == 1 or Xsignal.get() == 7:
8400  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8401  Iaxis_label = str(round(Iaxis_value, 3))
8402  XYca.create_text(x2+RightOffset, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize ))
8403  if YsignalVA.get() == 1:
8404  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8405  Vaxis_label = str(round(Vaxis_value, 3))
8406  XYca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8407  if YsignalVB.get() == 1:
8408  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8409  Vaxis_label = str(round(Vaxis_value, 3))
8410  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
8411  if YsignalM.get() == 1:
8412  TempCOLOR = COLORtrace5
8413  if MathTrace.get() == 2:
8414  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8415  elif MathTrace.get() == 3:
8416  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8417  else:
8418  if MathAxis == "V-A":
8419  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8420  TempCOLOR = COLORtrace1
8421  elif MathAxis == "V-B":
8422  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8423  TempCOLOR = COLORtrace2
8424  elif MathAxis == "I-A":
8425  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8426  TempCOLOR = COLORtrace3
8427  elif MathAxis == "I-B":
8428  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8429  TempCOLOR = COLORtrace4
8430  else:
8431  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8432  Vaxis_label = str(round(Vaxis_value, 3))
8433  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8434  if YsignalMX.get() == 1:
8435  TempCOLOR = COLORtrace6
8436  if MathXAxis == "V-A":
8437  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8438  TempCOLOR = COLORtrace1
8439  elif MathXAxis == "V-B":
8440  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8441  TempCOLOR = COLORtrace2
8442  elif MathXAxis == "I-A":
8443  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8444  TempCOLOR = COLORtrace3
8445  elif MathXAxis == "I-B":
8446  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8447  TempCOLOR = COLORtrace4
8448  else:
8449  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8450  Vaxis_label = str(round(Vaxis_value, 3))
8451  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8452  if YsignalMY.get() == 1:
8453  TempCOLOR = COLORtrace7
8454  if MathYAxis == "V-A":
8455  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8456  TempCOLOR = COLORtrace1
8457  elif MathYAxis == "V-B":
8458  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8459  TempCOLOR = COLORtrace2
8460  elif MathYAxis == "I-A":
8461  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8462  TempCOLOR = COLORtrace3
8463  elif MathYAxis == "I-B":
8464  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8465  TempCOLOR = COLORtrace4
8466  else:
8467  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8468  Vaxis_label = str(round(Vaxis_value, 3))
8469  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8470  i = i + 1
8471  # Draw vertical grid lines
8472  i = 0
8473  y1 = Y0TXY
8474  y2 = Y0TXY + GRHXY
8475  mg_siz = GRHXY/10.0
8476  mg_inc = mg_siz/5.0
8477  #
8478  while (i < 11):
8479  x = X0LXY + i * GRWXY/10.0
8480  Dline = [x,y1,x,y2]
8481  if (i == 5):
8482  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
8483  k = 0
8484  while (k < 10):
8485  l = 1
8486  while (l < 5):
8487  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
8488  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8489  l = l + 1
8490  k = k + 1
8491  if Xsignal.get() == 1 or Xsignal.get() == 6: #
8492  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8493  Vaxis_label = str(round(Vaxis_value, 3))
8494  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8495  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8496  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8497  Vaxis_label = str(round(Vaxis_value, 3))
8498  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8499  elif Xsignal.get() == 2:
8500  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8501  Iaxis_label = str(round(Iaxis_value, 3))
8502  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8503  elif Xsignal.get() == 4:
8504  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8505  Iaxis_label = str(round(Iaxis_value, 3))
8506  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8507  elif Xsignal.get() == 5:
8508  TempCOLOR = COLORtrace5
8509  if MathTrace.get() == 2:
8510  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8511  elif MathTrace.get() == 3:
8512  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8513  else:
8514  if MathXAxis == "V-A":
8515  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8516  TempCOLOR = COLORtrace1
8517  elif MathXAxis == "V-B":
8518  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8519  TempCOLOR = COLORtrace2
8520  elif MathXAxis == "I-A":
8521  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8522  TempCOLOR = COLORtrace3
8523  elif MathXAxis == "I-B":
8524  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8525  TempCOLOR = COLORtrace4
8526  else:
8527  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8528  TempCOLOR = COLORtrace5
8529  Vaxis_label = str(round(Vaxis_value, 3))
8530  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8531  else:
8532  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8533  if Xsignal.get() == 1 or Xsignal.get() == 6:
8534  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8535  Vaxis_label = str(round(Vaxis_value, 3))
8536  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8537  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8538  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8539  Vaxis_label = str(round(Vaxis_value, 3))
8540  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8541  elif Xsignal.get() == 2:
8542  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8543  Iaxis_label = str(round(Iaxis_value, 3))
8544  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8545  elif Xsignal.get() == 4:
8546  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8547  Iaxis_label = str(round(Iaxis_value, 3))
8548  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8549  elif Xsignal.get() == 5:
8550  TempCOLOR = COLORtrace5
8551  if MathTrace.get() == 2:
8552  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8553  elif MathTrace.get() == 3:
8554  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8555  else:
8556  if MathXAxis == "V-A":
8557  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8558  TempCOLOR = COLORtrace1
8559  elif MathXAxis == "V-B":
8560  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8561  TempCOLOR = COLORtrace2
8562  elif MathXAxis == "I-A":
8563  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8564  TempCOLOR = COLORtrace3
8565  elif MathXAxis == "I-B":
8566  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8567  TempCOLOR = COLORtrace4
8568  else:
8569  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8570  Vaxis_label = str(round(Vaxis_value, 3))
8571  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8572  i = i + 1
8573 # Draw traces
8574 # Avoid writing lines with 1 coordinate
8575  if YsignalVA.get() == 1:
8576  if len(XYlineVA) > 4:
8577  XYca.create_line(XYlineVA, fill=COLORtrace1, width=TRACEwidth.get())
8578  if YsignalIA.get() == 1:
8579  if len(XYlineIA) > 4:
8580  XYca.create_line(XYlineIA, fill=COLORtrace3, width=TRACEwidth.get())
8581  if YsignalVB.get() == 1:
8582  if len(XYlineVB) > 4:
8583  XYca.create_line(XYlineVB, fill=COLORtrace2, width=TRACEwidth.get())
8584  if YsignalIB.get() == 1:
8585  if len(XYlineIB) > 4:
8586  XYca.create_line(XYlineIB, fill=COLORtrace4, width=TRACEwidth.get())
8587  if YsignalM.get() == 1: # or Ysignal.get() == 5:
8588  if len(XYlineM) > 4:
8589  XYca.create_line(XYlineM, fill=COLORtrace5, width=TRACEwidth.get())
8590  if YsignalMX.get() == 1:
8591  if len(XYlineMX) > 4:
8592  XYca.create_line(XYlineMX, fill=COLORtrace6, width=TRACEwidth.get())
8593  if YsignalMY.get() == 1:
8594  if len(XYlineMY) > 4:
8595  XYca.create_line(XYlineMY, fill=COLORtrace7, width=TRACEwidth.get())
8596  if len(XYRlineVA) > 4 and XYRefAV.get() == 1:
8597  XYca.create_line(XYRlineVA, fill=COLORtraceR1, width=TRACEwidth.get())
8598  if len(XYRlineVB) > 4 and XYRefBV.get() == 1:
8599  XYca.create_line(XYRlineVB, fill=COLORtraceR2, width=TRACEwidth.get())
8600  if len(XYRlineIA) > 4 and XYRefAI.get() == 1:
8601  XYca.create_line(XYRlineIA, fill=COLORtraceR3, width=TRACEwidth.get())
8602  if len(XYRlineIB) > 4 and XYRefBI.get() == 1:
8603  XYca.create_line(XYRlineIB, fill=COLORtraceR4, width=TRACEwidth.get())
8604  if len(XYRlineM) > 4 and XYRefM.get() == 1:
8605  XYca.create_line(XYRlineM, fill=COLORtraceR5, width=TRACEwidth.get())
8606  if len(XYRlineMX) > 4 and XYRefMX.get() == 1:
8607  XYca.create_line(XYRlineMX, fill=COLORtraceR6, width=TRACEwidth.get())
8608  if len(XYRlineMY) > 4 and XYRefMY.get() == 1:
8609  XYca.create_line(XYRlineMY, fill=COLORtraceR7, width=TRACEwidth.get())
8610 # Draw Histogram Traces
8611  if Xsignal.get() == 6:
8612  MakeHistogram()
8613  b = 0
8614  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8615  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
8616  y1 = Y0TXY + GRHXY
8617  # print Yconv1, y1
8618  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
8619  while b < 4999: #
8620  if HistAsPercent == 1: # convert to percent of total sample count
8621  ylo = float(HBuffA[0][b]) / len(VBuffA)
8622  ylo = ylo * 100.0
8623  else:
8624  ylo = HBuffA[0][b] #
8625  ylo = int(y1 - (Yconv1 * ylo))
8626  if ylo > Ymax:
8627  ylo = Ymax
8628  if ylo < Ymin:
8629  ylo = Ymin
8630  xlo = HBuffA[1][b] - CHAOffset
8631  xlo = int(c2 + Xconv1 * xlo)
8632  Dline = [xlo,y1,xlo,ylo]
8633  XYca.create_line(Dline, fill=COLORtrace1)
8634  b = b + 1
8635  if Xsignal.get() == 7:
8636  MakeHistogram()
8637  b = 0
8638  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8639  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
8640  y1 = Y0TXY + GRHXY
8641  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
8642  while b < 4999: #
8643  if HistAsPercent == 1: # convert to percent
8644  ylo = float(HBuffB[0][b]) / len(VBuffB)
8645  ylo = ylo * 100.0
8646  else:
8647  ylo = HBuffB[0][b]
8648  ylo = int(y1 - Yconv1 * ylo)
8649  if ylo > Ymax:
8650  ylo = Ymax
8651  if ylo < Ymin:
8652  ylo = Ymin
8653  xlo = HBuffB[1][b] - CHBOffset
8654  xlo = int(c2 + Xconv1 * xlo)
8655  Dline = [xlo,y1,xlo,ylo]
8656  XYca.create_line(Dline, fill=COLORtrace2)
8657  b = b + 1
8658 # Draw X - Y Cursor lines if required
8659  COLORXmarker = COLORtrace1
8660  COLORYmarker = COLORtrace2
8661  if Xsignal.get() == 1 or Xsignal.get() == 6:
8662  Xconv1 = float(GRWXY/10) / CH1pdvRange
8663  Xoffset1 = CHAOffset
8664  COLORXmarker = COLORtrace1
8665  X_label = " V"
8666  if Xsignal.get() == 2:
8667  Xconv1 = float(GRWXY/10) / CH1IpdvRange
8668  Xoffset1 = CHAIOffset
8669  COLORXmarker = COLORtrace3
8670  X_label = " mA"
8671  if Xsignal.get() == 3 or Xsignal.get() == 7:
8672  Xconv1 = float(GRWXY/10) / CH2pdvRange
8673  Xoffset1 = CHBOffset
8674  COLORXmarker = COLORtrace2
8675  X_label = " V"
8676  if Xsignal.get() == 4:
8677  Xconv1 = float(GRWXY/10) / CH2IpdvRange
8678  Xoffset1 = CHBIOffset
8679  COLORmarker = COLORtrace4
8680  X_label = " mA"
8681  if Xsignal.get() == 5:
8682  X_label = MathXUnits
8683  if MathXAxis == "V-A":
8684  Xconv1 = float(GRWXY/10) / CH1pdvRange
8685  Xoffset1 = CHAOffset
8686  COLORXmarker = COLORtrace1
8687  elif MathXAxis == "V-B":
8688  Xconv1 = float(GRWXY/10) / CH2pdvRange
8689  Xoffset1 = CHBOffset
8690  COLORXmarker = COLORtrace2
8691  elif MathXAxis == "I-A":
8692  Xconv1 = float(GRWXY/10) / CH1IpdvRange
8693  Xoffset1 = CHAIOffset
8694  COLORXmarker = COLORtrace3
8695  elif MathXAxis == "I-B":
8696  Xconv1 = float(GRWXY/10) / CH2IpdvRange
8697  Xoffset1 = CHBIOffset
8698  COLORXmarker = COLORtrace4
8699  else:
8700  Xconv1 = float(GRWXY/10) / CH1pdvRange
8701  Xoffset1 = CHAOffset
8702  COLORXmarker = COLORtrace1
8703 #
8704  if YsignalVA.get() == 1 or YsignalM.get() == 1:
8705  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8706  Yoffset1 = CHAOffset
8707  COLORYmarker = COLORtrace1
8708  Y_label = " V"
8709  if YsignalIA.get() == 1:
8710  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8711  Yoffset1 = CHAIOffset
8712  COLORYmarker = COLORtrace3
8713  Y_label = " mA"
8714  if YsignalVB.get() == 1 or YsignalM.get() == 1:
8715  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
8716  Yoffset1 = CHBOffset
8717  COLORYmarker = COLORtrace2
8718  Y_label = " V"
8719  if YsignalIB.get() == 1:
8720  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8721  Yoffset1 = CHBIOffset
8722  COLORYmarker = COLORtrace4
8723  Y_label = " mA"
8724  if YsignalM.get() == 1 or YsignalMX.get() == 1 or YsignalMY.get() == 1:
8725  Y_label = MathYUnits
8726  if MathYAxis == "V-A":
8727  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8728  Yoffset1 = CHAOffset
8729  COLORYmarker = COLORtrace1
8730  elif MathYAxis == "V-B":
8731  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
8732  Yoffset1 = CHBOffset
8733  COLORYmarker = COLORtrace2
8734  elif MathYAxis == "I-A":
8735  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8736  Yoffset1 = CHAIOffset
8737  COLORYmarker = COLORtrace3
8738  elif MathYAxis == "I-B":
8739  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8740  Yoffset1 = CHBIOffset
8741  COLORYmarker = COLORtrace4
8742  else:
8743  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8744  Yoffset1 = CHAOffset
8745  COLORYmarker = COLORtrace1
8746  if ShowXCur.get() > 0:
8747  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
8748  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
8749  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
8750  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
8751  XString = ' {0:.3f} '.format(xvolts)
8752  V_label = XString + X_label
8753  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
8754  if ShowYCur.get() > 0:
8755  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
8756  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
8757  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
8758  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
8759  V1String = ' {0:.3f} '.format(-yvolts)
8760  V_label = V1String + Y_label
8761  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
8762  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
8763  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
8764  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
8765  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
8766  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
8767  xvolts = Xoffset1 - ((c1-MouseX)/Xconv1) # XCursor
8768  XString = ' {0:.3f} '.format(xvolts)
8769  V_label = XString + X_label
8770  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
8771  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
8772  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
8773  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
8774  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
8775  V1String = ' {0:.3f} '.format(-yvolts)
8776  V_label = V1String + Y_label
8777  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
8778 #
8779 # General information on top of the grid
8780 # Sweep information
8781  sttxt = "Running"
8782  if TRACEmodeTime.get() == 1:
8783  sttxt = sttxt + " Averaging"
8784  if ManualTrigger.get() == 1:
8785  sttxt = "Manual Trigger"
8786  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
8787  sttxt = "Stopped"
8788  if ScreenXYrefresh.get() == 1:
8789  sttxt = sttxt + " Persistance ON"
8790  # Delete text at bottom of screen
8791  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
8792  for n in de:
8793  XYca.delete(n)
8794  # Delete text at top of screen
8795  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
8796  for n in de:
8797  XYca.delete(n)
8798  if LabelPlotText.get() > 0:
8799  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8800  else:
8801  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8802  x = X0LXY
8803  y = 12
8804  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8805  # digital I/O indicators
8806  x2 = X0LXY + GRWXY
8807  BoxColor = "#808080" # gray
8808  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
8809  if D0.get() == 0 and D4.get() == 0:
8810  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
8811  if Dval[0] == 1:
8812  BoxColor = "#00ff00" # 100% green
8813  elif Dval[0] == 0:
8814  BoxColor = "#ff0000" # 100% red
8815  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
8816  else:
8817  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
8818  if D1.get() == 0 and D5.get() == 0:
8819  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
8820  if Dval[0] == 1:
8821  BoxColor = "#00ff00" # 100% green
8822  elif Dval[0] == 0:
8823  BoxColor = "#ff0000" # 100% red
8824  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
8825  else:
8826  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
8827  if D2.get() == 0 and D6.get() == 0:
8828  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
8829  if Dval[0] == 1:
8830  BoxColor = "#00ff00" # 100% green
8831  elif Dval[0] == 0:
8832  BoxColor = "#ff0000" # 100% red
8833  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
8834  else:
8835  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
8836  if D3.get() == 0 and D7.get() == 0:
8837  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
8838  if Dval[0] == 1:
8839  BoxColor = "#00ff00" # 100% green
8840  elif Dval[0] == 0:
8841  BoxColor = "#ff0000" # 100% red
8842  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
8843  else:
8844  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
8845  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
8846  # print period and frequency of displayed channels
8847  txt = " "
8848  if Xsignal.get() == 1 or Xsignal.get() == 3:
8849  FindRisingEdge(VBuffA, VBuffB)
8850  if Xsignal.get() == 1:
8851  if MeasAHW.get() == 1:
8852  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
8853  if MeasALW.get() == 1:
8854  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
8855  if MeasADCy.get() == 1:
8856  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8857  if MeasAPER.get() == 1:
8858  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
8859  if MeasAFREQ.get() == 1:
8860  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8861  if Xsignal.get() == 3:
8862  if MeasBHW.get() == 1:
8863  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
8864  if MeasBLW.get() == 1:
8865  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
8866  if MeasBDCy.get() == 1:
8867  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8868  if MeasBPER.get() == 1:
8869  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
8870  if MeasBFREQ.get() == 1:
8871  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8872  if MeasPhase.get() == 1:
8873  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8874 
8875  x = X0LXY
8876  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
8877  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8878  txt = " "
8879  if Xsignal.get() == 1 or YsignalVA.get() == 1 or Xsignal.get() == 6:
8880  # Channel A information
8881  txt = "CHA: "
8882  txt = txt + str(CH1pdvRange) + " V/div"
8883  if MeasDCV1.get() == 1:
8884  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8885  if MeasMaxV1.get() == 1:
8886  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8887  if MeasTopV1.get() == 1:
8888  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8889  if MeasMinV1.get() == 1:
8890  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8891  if MeasBaseV1.get() == 1:
8892  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
8893  if MeasMidV1.get() == 1:
8894  MidV1 = (MaxV1+MinV1)/2
8895  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8896  if MeasPPV1.get() == 1:
8897  PPV1 = MaxV1-MinV1
8898  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8899  if MeasRMSV1.get() == 1:
8900  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8901  if MeasUserA.get() == 1:
8902  try:
8903  TempValue = eval(UserAString)
8904  V1String = ' {0:.4f} '.format(TempValue)
8905  except:
8906  V1String = "####"
8907  txt = txt + UserALabel + " = " + V1String
8908  if Xsignal.get() == 2:
8909  txt = "CHA: "
8910  txt = txt + str(CH1IpdvRange) + " mA/div"
8911  elif (Xsignal.get() == 2):
8912  txt = txt + "CHA: "
8913  txt = txt + str(CH1IpdvRange) + " mA/div"
8914  if Xsignal.get() == 2 or YsignalIA.get() == 1:
8915  if MeasDCI1.get() == 1:
8916  V1String = ' {0:.2f} '.format(DCI1)
8917  txt = txt + " AvgI = " + V1String
8918  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8919  try:
8920  Resvalue = (DCV1/DCI1)*1000
8921  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8922  except:
8923  txt = txt + " Res = OverRange"
8924  if MeasMaxI1.get() == 1:
8925  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8926  if MeasMinI1.get() == 1:
8927  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8928  if MeasMidI1.get() == 1:
8929  MidI1 = (MaxI1+MinI1)/2
8930  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8931  if MeasPPI1.get() == 1:
8932  PPI1 = MaxI1-MinI1
8933  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8934  if MeasRMSI1.get() == 1:
8935  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
8936 
8937  x = X0LXY
8938  y = Y0TXY+GRHXY+int(4*FontSize) # 32
8939  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8940  txt= " "
8941  # Channel B information
8942  if Xsignal.get() == 3 or YsignalVB.get() == 1 or Xsignal.get() == 7:
8943  txt = "CHB: "
8944  txt = txt + str(CH2pdvRange) + " V/div"
8945  if MeasDCV2.get() == 1:
8946  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8947  if MeasMaxV2.get() == 1:
8948  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8949  if MeasTopV2.get() == 1:
8950  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8951  if MeasMinV2.get() == 1:
8952  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8953  if MeasBaseV2.get() == 1:
8954  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
8955  if MeasMidV2.get() == 1:
8956  MidV2 = (MaxV2+MinV2)/2
8957  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8958  if MeasPPV2.get() == 1:
8959  PPV2 = MaxV2-MinV2
8960  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8961  if MeasRMSV2.get() == 1:
8962  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8963  if MeasUserB.get() == 1:
8964  try:
8965  TempValue = eval(UserBString)
8966  V1String = ' {0:.4f} '.format(TempValue)
8967  except:
8968  V1String = "####"
8969  txt = txt + UserBLabel + " = " + V1String
8970  if Xsignal.get() == 4:
8971  txt = "CHB: "
8972  txt = txt + str(CH2IpdvRange) + " mA/div"
8973  elif Xsignal.get() == 4:
8974  txt = txt + "CHB: "
8975  txt = txt + str(CH2IpdvRange) + " mA/div"
8976  if Xsignal.get() == 4 or YsignalIB.get() == 1:
8977  if MeasDCI2.get() == 1:
8978  V1String = ' {0:.2f} '.format(DCI2)
8979  txt = txt + " AvgI = " + V1String
8980  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8981  try:
8982  Resvalue = (DCV2/DCI2)*1000
8983  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8984  except:
8985  txt = txt + " Res = OverRange"
8986  if MeasMaxI2.get() == 1:
8987  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8988  if MeasMinI2.get() == 1:
8989  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8990  if MeasMidI2.get() == 1:
8991  MidI2 = (MaxI2+MinI2)/2
8992  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8993  if MeasPPI2.get() == 1:
8994  PPI2 = MaxI2-MinI2
8995  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8996  if MeasRMSI2.get() == 1:
8997  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
8998 
8999  x = X0LXY
9000  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
9001  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
9002 #
9004  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9005 
9006  if MarkerScale.get() != 1:
9007  MarkerScale.set(1)
9008  CHAlab.config(style="Rtrace1.TButton")
9009  CHBlab.config(style="Strace2.TButton")
9010  CHAIlab.config(style="Strace3.TButton")
9011  CHBIlab.config(style="Strace4.TButton")
9012  else:
9013  MarkerScale.set(0)
9014 #
9016  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9017 
9018  if MarkerScale.get() != 3:
9019  MarkerScale.set(3)
9020  CHAlab.config(style="Strace1.TButton")
9021  CHBlab.config(style="Strace2.TButton")
9022  CHAIlab.config(style="Rtrace3.TButton")
9023  CHBIlab.config(style="Strace4.TButton")
9024  else:
9025  MarkerScale.set(0)
9026 
9028  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9029 
9030  if MarkerScale.get() != 2:
9031  MarkerScale.set(2)
9032  CHAlab.config(style="Strace1.TButton")
9033  CHBlab.config(style="Rtrace2.TButton")
9034  CHAIlab.config(style="Strace3.TButton")
9035  CHBIlab.config(style="Strace4.TButton")
9036  else:
9037  MarkerScale.set(0)
9038 
9040  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9041 
9042  if MarkerScale.get() != 3:
9043  MarkerScale.set(4)
9044  CHAlab.config(style="Strace1.TButton")
9045  CHBlab.config(style="Strace2.TButton")
9046  CHAIlab.config(style="Strace3.TButton")
9047  CHBIlab.config(style="Rtrace4.TButton")
9048  else:
9049  MarkerScale.set(0)
9050 #
9052  global MarkerXYScale, CHAxylab, CHBxylab
9053 
9054  MarkerXYScale.set(1)
9055  CHAxylab.config(style="Rtrace1.TButton")
9056  CHBxylab.config(style="Strace2.TButton")
9057 
9059  global MarkerXYScale, CHAxylab, CHBxylab
9060 
9061  MarkerXYScale.set(2)
9062  CHBxylab.config(style="Rtrace2.TButton")
9063  CHAxylab.config(style="Strace1.TButton")
9064 #
9066  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
9067 
9068  TCursor = event.x
9069  VCursor = event.y
9070  if RUNstatus.get() == 0:
9072  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
9073 
9075  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca, MWcount
9076  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
9077 
9078  ShiftKeyDwn = event.state & 1
9079  if event.widget == ca:
9080  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
9081  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
9082  # respond to Linux or Windows wheel event
9083  if event.num == 5 or event.delta == -120:
9084  TCursor -= 1
9085  if event.num == 4 or event.delta == 120:
9086  TCursor += 1
9087  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
9088  # respond to Linux or Windows wheel event
9089  if event.num == 5 or event.delta == -120:
9090  VCursor += 1
9091  if event.num == 4 or event.delta == 120:
9092  VCursor -= 1
9093 
9097  else:
9098  if MeasGateStatus.get() == 1:
9099  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
9100  if ShiftKeyDwn == 0:
9101  if event.num == 5 or event.delta == -120:
9102  MeasGateLeft = MeasGateLeft + (-100 * Tstep)
9103  if event.num == 4 or event.delta == 120:
9104  MeasGateLeft = MeasGateLeft + (100 * Tstep)
9105  # MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
9106  if ShiftKeyDwn == 1:
9107  if event.num == 5 or event.delta == -120:
9108  MeasGateRight = MeasGateRight + (-100 * Tstep)
9109  if event.num == 4 or event.delta == 120:
9110  MeasGateRight = MeasGateRight + (100 * Tstep)
9111  #MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
9112  try:
9113  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
9114  except:
9115  donothing()
9116  if RUNstatus.get() == 0:
9118 
9119 def onCanvasUpArrow(event):
9120  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
9121 
9122  shift_key = event.state & 1
9123  if event.widget == ca:
9124  if ShowVCur.get() > 0 and shift_key == 0:
9125  VCursor = VCursor - 1
9126  elif ShowVCur.get() > 0 and shift_key == 1:
9127  VCursor = VCursor - 5
9128  if RUNstatus.get() == 0:
9130  try:
9131  if event.widget == XYca:
9132  if ShowYCur.get() > 0 and shift_key == 0:
9133  YCursor = YCursor - 1
9134  elif ShowYCur.get() > 0 and shift_key == 1:
9135  YCursor = YCursor - 5
9136  if RUNstatus.get() == 0:
9137  UpdateXYScreen()
9138  except:
9139  donothing()
9140  try:
9141  if event.widget == Freqca:
9142  if ShowdBCur.get() > 0 and shift_key == 0:
9143  dBCursor = dBCursor - 1
9144  elif ShowdBCur.get() > 0 and shift_key == 1:
9145  dBCursor = dBCursor - 5
9146  if RUNstatus.get() == 0:
9148  except:
9149  donothing()
9150  try:
9151  if event.widget == Bodeca:
9152  if ShowBdBCur.get() > 0 and shift_key == 0:
9153  BdBCursor = BdBCursor - 1
9154  elif ShowBdBCur.get() > 0 and shift_key == 1:
9155  BdBCursor = BdBCursor - 5
9156  if RUNstatus.get() == 0:
9158  except:
9159  donothing()
9160 
9162  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
9163 
9164  shift_key = event.state & 1
9165  if event.widget == ca:
9166  if ShowVCur.get() > 0 and shift_key == 0:
9167  VCursor = VCursor + 1
9168  elif ShowVCur.get() > 0 and shift_key == 1:
9169  VCursor = VCursor + 5
9170  if RUNstatus.get() == 0:
9172  try:
9173  if event.widget == XYca:
9174  if ShowYCur.get() > 0 and shift_key == 0:
9175  YCursor = YCursor + 1
9176  elif ShowYCur.get() > 0 and shift_key == 1:
9177  YCursor = YCursor + 5
9178  if RUNstatus.get() == 0:
9179  UpdateXYScreen()
9180  except:
9181  donothing()
9182  try:
9183  if event.widget == Freqca:
9184  if ShowdBCur.get() > 0 and shift_key == 0:
9185  dBCursor = dBCursor + 1
9186  elif ShowdBCur.get() > 0 and shift_key == 1:
9187  dBCursor = dBCursor + 5
9188  if RUNstatus.get() == 0:
9190  except:
9191  donothing()
9192  try:
9193  if event.widget == Bodeca:
9194  if ShowBdBCur.get() > 0 and shift_key == 0:
9195  BdBCursor = BdBCursor + 1
9196  elif ShowBdBCur.get() > 0 and shift_key == 1:
9197  BdBCursor = BdBCursor + 5
9198  if RUNstatus.get() == 0:
9200  except:
9201  donothing()
9202 
9204  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9205 
9206  shift_key = event.state & 1
9207  if event.widget == ca:
9208  if ShowTCur.get() > 0 and shift_key == 0:
9209  TCursor = TCursor - 1
9210  elif ShowTCur.get() > 0 and shift_key == 1:
9211  TCursor = TCursor - 5
9212  if RUNstatus.get() == 0:
9214  try:
9215  if event.widget == XYca:
9216  if ShowXCur.get() > 0 and shift_key == 0:
9217  XCursor = XCursor - 1
9218  elif ShowXCur.get() > 0 and shift_key == 1:
9219  XCursor = XCursor - 5
9220  if RUNstatus.get() == 0:
9221  UpdateXYScreen()
9222  except:
9223  donothing()
9224  try:
9225  if event.widget == Freqca:
9226  if ShowFCur.get() > 0 and shift_key == 0:
9227  FCursor = FCursor - 1
9228  elif ShowFCur.get() > 0 and shift_key == 1:
9229  FCursor = FCursor - 5
9230  if RUNstatus.get() == 0:
9232  except:
9233  donothing()
9234  try:
9235  if event.widget == Bodeca:
9236  if ShowBPCur.get() > 0 and shift_key == 0:
9237  BPCursor = BPCursor - 1
9238  elif ShowBPCur.get() > 0 and shift_key == 1:
9239  BPCursor = BPCursor - 5
9240  if RUNstatus.get() == 0:
9242  except:
9243  donothing()
9244 
9246  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9247 
9248  shift_key = event.state & 1
9249  if event.widget == ca:
9250  if ShowTCur.get() > 0 and shift_key == 0:
9251  TCursor = TCursor + 1
9252  elif ShowTCur.get() > 0 and shift_key == 1:
9253  TCursor = TCursor + 5
9254  if RUNstatus.get() == 0:
9256  try:
9257  if event.widget == XYca:
9258  if ShowXCur.get() > 0 and shift_key == 0:
9259  XCursor = XCursor + 1
9260  elif ShowXCur.get() > 0 and shift_key == 1:
9261  XCursor = XCursor + 5
9262  if RUNstatus.get() == 0:
9263  UpdateXYScreen()
9264  except:
9265  donothing()
9266  try:
9267  if event.widget == Freqca:
9268  if ShowFCur.get() > 0 and shift_key == 0:
9269  FCursor = FCursor + 1
9270  elif ShowFCur.get() > 0 and shift_key == 1:
9271  FCursor = FCursor + 5
9272  if RUNstatus.get() == 0:
9274  except:
9275  donothing()
9276  try:
9277  if event.widget == Bodeca:
9278  if ShowBPCur.get() > 0 and shift_key == 0:
9279  BPCursor = BPCursor + 1
9280  elif ShowBPCur.get() > 0 and shift_key == 1:
9281  BPCursor = BPCursor + 5
9282  if RUNstatus.get() == 0:
9284  except:
9285  donothing()
9286 
9287 def onCanvasSpaceBar(event):
9288  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
9289 
9290  if event.widget == ca:
9291  if RUNstatus.get() == 0:
9292  BStart()
9293  elif RUNstatus.get() > 0:
9294  BStop()
9295  try:
9296  if event.widget == XYca:
9297  if RUNstatus.get() == 0:
9298  BStart()
9299  elif RUNstatus.get() > 0:
9300  BStop()
9301  except:
9302  donothing()
9303  try:
9304  if event.widget == IAca:
9305  if RUNstatus.get() == 0:
9306  BStart()
9307  elif RUNstatus.get() > 0:
9308  BStop()
9309  except:
9310  donothing()
9311  try:
9312  if event.widget == Freqca:
9313  if RUNstatus.get() == 0:
9314  BStartSA()
9315  elif RUNstatus.get() > 0:
9316  BStopSA()
9317  except:
9318  donothing()
9319  try:
9320  if event.widget == Bodeca:
9321  if RUNstatus.get() == 0:
9322  BStartBP()
9323  elif RUNstatus.get() > 0:
9324  BStopBP()
9325  except:
9326  donothing()
9327 #
9329  global X0L # Left top X value
9330  global Y0T # Left top Y value
9331  global GRW # Screenwidth
9332  global GRH # Screenheight
9333  global FontSize
9334  global ca, MarkerLoc, Mulx, Roll_Mode
9335  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9336  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
9337  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
9338  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
9339  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9340  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9341  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9342  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
9343  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
9344  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
9345 
9346  try:
9347  HoldOff = float(eval(HoldOffentry.get()))
9348  if HoldOff < 0:
9349  HoldOff = 0
9350  except:
9351  HoldOffentry.delete(0,END)
9352  HoldOffentry.insert(0, HoldOff)
9353  # get time scale
9354  try:
9355  TIMEdiv = float(eval(TMsb.get()))
9356  except:
9357  TIMEdiv = 0.5
9358  TMsb.delete(0,"end")
9359  TMsb.insert(0,TIMEdiv)
9360  # prevent divide by zero error
9361  if TIMEdiv < 0.0002:
9362  TIMEdiv = 0.01
9363  # add markers only if stopped
9364  if (RUNstatus.get() == 0):
9365  MarkerNum = MarkerNum + 1
9366  # get the vertical ranges
9367  try:
9368  CH1pdvRange = float(eval(CHAsb.get()))
9369  except:
9370  CHAsb.delete(0,END)
9371  CHAsb.insert(0, CH1pdvRange)
9372  try:
9373  CH2pdvRange = float(eval(CHBsb.get()))
9374  except:
9375  CHBsb.delete(0,END)
9376  CHBsb.insert(0, CH2pdvRange)
9377  try:
9378  CH1IpdvRange = float(eval(CHAIsb.get()))
9379  except:
9380  CHAIsb.delete(0,END)
9381  CHAIsb.insert(0, CH1IpdvRange)
9382  try:
9383  CH2IpdvRange = float(eval(CHBIsb.get()))
9384  except:
9385  CHBIsb.delete(0,END)
9386  CHBIsb.insert(0, CH2IpdvRange)
9387  # get the vertical offsets
9388  try:
9389  CHAOffset = float(eval(CHAVPosEntry.get()))
9390  except:
9391  CHAVPosEntry.delete(0,END)
9392  CHAVPosEntry.insert(0, CHAOffset)
9393  try:
9394  CHAIOffset = float(eval(CHAIPosEntry.get()))
9395  except:
9396  CHAIPosEntry.delete(0,END)
9397  CHAIPosEntry.insert(0, CHAIOffset)
9398  try:
9399  CHBOffset = float(eval(CHBVPosEntry.get()))
9400  except:
9401  CHBVPosEntry.delete(0,END)
9402  CHBVPosEntry.insert(0, CHBOffset)
9403  try:
9404  CHBIOffset = float(eval(CHBIPosEntry.get()))
9405  except:
9406  CHBIPosEntry.delete(0,END)
9407  CHBIPosEntry.insert(0, CHBIOffset)
9408  # prevent divide by zero error
9409  if CH1pdvRange < 0.001:
9410  CH1pdvRange = 0.001
9411  if CH2pdvRange < 0.001:
9412  CH2pdvRange = 0.001
9413  if CH1IpdvRange < 1.0:
9414  CH1IpdvRange = 1.0
9415  if CH2IpdvRange < 1.0:
9416  CH2IpdvRange = 1.0
9417 #
9418  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
9419  try:
9420  CHMApdvRange = float(eval(CHB_Asb.get()))
9421  except:
9422  CHB_Asb.delete(0,END)
9423  CHB_Asb.insert(0, CHMApdvRange)
9424  try:
9425  CHMBpdvRange = float(eval(CHB_Bsb.get()))
9426  except:
9427  CHB_Bsb.delete(0,END)
9428  CHB_Bsb.insert(0, CHMBpdvRange)
9429  try:
9430  CHMCpdvRange = float(eval(CHB_Csb.get()))
9431  except:
9432  CHB_Csb.delete(0,END)
9433  CHB_Csb.insert(0, CHMCpdvRange)
9434  try:
9435  CHMDpdvRange = float(eval(CHB_Dsb.get()))
9436  except:
9437  CHB_Dsb.delete(0,END)
9438  CHB_Dsb.insert(0, CHMDpdvRange)
9439  YconvMA = float(GRH/10.0) / CHMApdvRange
9440  YconvMB = float(GRH/10.0) / CHMBpdvRange
9441  YconvMC = float(GRH/10.0) / CHMCpdvRange
9442  YconvMD = float(GRH/10.0) / CHMDpdvRange
9443  try:
9444  CHBAOffset = float(eval(CHB_APosEntry.get()))
9445  except:
9446  CHB_APosEntry.delete(0,END)
9447  CHB_APosEntry.insert(0, CHBAOffset)
9448  try:
9449  CHBBOffset = float(eval(CHB_BPosEntry.get()))
9450  except:
9451  CHB_BPosEntry.delete(0,END)
9452  CHB_BPosEntry.insert(0, CHBBOffset)
9453  try:
9454  CHBCOffset = float(eval(CHB_CPosEntry.get()))
9455  except:
9456  CHB_CPosEntry.delete(0,END)
9457  CHB_CPosEntry.insert(0, CHBCOffset)
9458  try:
9459  CHBDOffset = float(eval(CHB_DPosEntry.get()))
9460  except:
9461  CHB_DPosEntry.delete(0,END)
9462  CHB_DPosEntry.insert(0, CHBDOffset)
9463  Yoffset1 = CHAOffset
9464  if MarkerScale.get() == 1:
9465  Yconv1 = float(GRH/10.0) / CH1pdvRange
9466  Yoffset1 = CHAOffset
9467  COLORmarker = COLORtrace1
9468  Units = " V"
9469  elif MarkerScale.get() == 2:
9470  Yconv1 = float(GRH/10.0) / CH2pdvRange
9471  Yoffset1 = CHBOffset
9472  COLORmarker = COLORtrace2
9473  Units = " V"
9474  elif MarkerScale.get() == 3:
9475  Yconv1 = float(GRH/10.0) / CH1IpdvRange
9476  Yoffset1 = CHAIOffset
9477  COLORmarker = COLORtrace3
9478  Units = " mA"
9479  elif MarkerScale.get() == 4:
9480  Yconv1 = float(GRH/10.0) / CH2IpdvRange
9481  Yoffset1 = CHBIOffset
9482  COLORmarker = COLORtrace4
9483  Units = " mA"
9484  # Aanalog Mux settings
9485  elif MarkerScale.get() == 5:
9486  Yconv1 = float(GRH/10.0) / CHMApdvRange
9487  Yoffset1 = CHBAOffset
9488  COLORmarker = COLORtrace2
9489  Units = " V"
9490  elif MarkerScale.get() == 6:
9491  Yconv1 = float(GRH/10.0) / CHMBpdvRange
9492  Yoffset1 = CHBBOffset
9493  COLORmarker = COLORtrace6
9494  Units = " V"
9495  elif MarkerScale.get() == 7:
9496  Yconv1 = float(GRH/10.0) / CHMCpdvRange
9497  Yoffset1 = CHBCOffset
9498  COLORmarker = COLORtrace7
9499  Units = " V"
9500  elif MarkerScale.get() == 8:
9501  Yconv1 = float(GRH/10.0) / CHMDpdvRange
9502  Yoffset1 = CHBDOffset
9503  COLORmarker = COLORtrace4
9504  Units = " V"
9505  else:
9506  Yconv1 = float(GRH/10.0) / CH1pdvRange
9507  Yoffset1 = CHAOffset
9508  COLORmarker = COLORtrace1
9509  Units = " V"
9510  #
9511  c1 = GRH / 2.0 + Y0T # fixed correction channel A
9512  xc1 = GRW / 2.0 + X0L
9513  c2 = GRH / 2.0 + Y0T # fixed correction channel B
9514  # draw X at marker point and number
9515  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9516  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9517  # DISsamples = (10.0 * TIMEdiv) # grid width in time
9518  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9519  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
9520  #
9521  Tpoint = Tpoint/Mulx
9522  if Tpoint >= 1000:
9523  axis_value = Tpoint / 1000.0
9524  TString = ' {0:.2f} '.format(axis_value) + " S "
9525  if Tpoint < 1000 and Tpoint >= 1:
9526  axis_value = Tpoint
9527  TString = ' {0:.2f} '.format(axis_value) + " mS "
9528  if Tpoint < 1:
9529  axis_value = Tpoint * 1000.0
9530  TString = ' {0:.2f} '.format(axis_value) + " uS "
9531  # TString = ' {0:.2f} '.format(Tpoint)
9532  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
9533  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
9534  V1String = ' {0:.3f} '.format(-yvolts)
9535  else:
9536  V1String = ' {0:.1f} '.format(-yvolts)
9537  V_label = str(MarkerNum) + " " + TString + V1String
9538  V_label = V_label + Units
9539  if MarkerNum > 1:
9540  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
9541  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
9542  else:
9543  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
9544  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
9545  DT = (Tpoint-PrevT)
9546  if Tpoint >= 1000:
9547  axis_value = DT / 1000.0
9548  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
9549  if Tpoint < 1000 and Tpoint >= 1:
9550  axis_value = DT
9551  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
9552  if Tpoint < 1:
9553  axis_value = DT * 1000.0
9554  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
9555  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
9556  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
9557  V_label = V_label + " Delta " + DeltaT + DeltaV
9558  V_label = V_label + Units
9559  V_label = V_label + ", Freq " + DFreq + " KHz"
9560  else:
9561  V_label = V_label + " Delta " + DeltaV + Units
9562  # place in upper left unless specified otherwise
9563  x = X0L + 5
9564  y = Y0T + 3 + (MarkerNum*10)
9565  Justify = 'w'
9566  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
9567  x = X0L + GRW - 5
9568  y = Y0T + 3 + (MarkerNum*10)
9569  Justify = 'e'
9570  if MarkerLoc == 'LL' or MarkerLoc == 'll':
9571  x = X0L + 5
9572  y = Y0T + GRH + 3 - (MarkerNum*10)
9573  Justify = 'w'
9574  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
9575  x = X0L + GRW - 5
9576  y = Y0T + GRH + 3 - (MarkerNum*10)
9577  Justify = 'e'
9578  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
9579  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
9580  PrevV = yvolts
9581  PrevT = Tpoint
9582  else:
9583  if MeasGateStatus.get() == 1:
9584  #DISsamples = (10.0 * TIMEdiv) # grid width in time
9585  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9586  if MeasGateNum == 0:
9587  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
9588  MeasGateNum = 1
9589  else:
9590  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
9591  MeasGateNum = 0
9592  LeftGate = X0L + MeasGateLeft / Tstep
9593  RightGate = X0L + MeasGateRight / Tstep
9594  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
9595  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
9596 
9597 #
9598 def onCanvasOne(event):
9599  global ShowC1_V
9600 
9601  if ShowC1_V.get() == 0:
9602  ShowC1_V.set(1)
9603  else:
9604  ShowC1_V.set(0)
9605 #
9606 def onCanvasTwo(event):
9607  global ShowC2_V
9608 
9609  if ShowC2_V.get() == 0:
9610  ShowC2_V.set(1)
9611  else:
9612  ShowC2_V.set(0)
9613 #
9614 def onCanvasThree(event):
9615  global ShowC1_I
9616 
9617  if ShowC1_I.get() == 0:
9618  ShowC1_I.set(1)
9619  else:
9620  ShowC1_I.set(0)
9621 #
9622 def onCanvasFour(event):
9623  global ShowC2_I
9624 
9625  if ShowC2_I.get() == 0:
9626  ShowC2_I.set(1)
9627  else:
9628  ShowC2_I.set(0)
9629 #
9630 def onCanvasFive(event):
9631  global MathTrace
9632 
9633  MathTrace.set(1)
9634 #
9635 def onCanvasSix(event):
9636  global MathTrace
9637 
9638  MathTrace.set(2)
9639 #
9640 def onCanvasSeven(event):
9641  global MathTrace
9642 
9643  MathTrace.set(3)
9644 #
9645 def onCanvasEight(event):
9646  global MathTrace
9647 
9648  MathTrace.set(10)
9649 #
9650 def onCanvasNine(event):
9651  global MathTrace
9652 
9653  MathTrace.set(12)
9654 #
9655 def onCanvasZero(event):
9656  global MathTrace
9657 
9658  MathTrace.set(0)
9659 #
9660 def onCanvasTrising(event):
9661  global TgEdge
9662 
9663  TgEdge.set(0)
9664 #
9665 def onCanvasTfalling(event):
9666  global TgEdge
9667 
9668  TgEdge.set(1)
9669 #
9670 def onCanvasSnap(event):
9671 
9672  BSnapShot()
9673 #
9674 def onCanvasAverage(event):
9675  global TRACEmodeTime
9676 
9677  if TRACEmodeTime.get() == 0:
9678  TRACEmodeTime.set(1)
9679  else:
9680  TRACEmodeTime.set(0)
9681 #
9682 def onCanvasShowTcur(event):
9683  global ShowTCur
9684 
9685  if ShowTCur.get() == 0:
9686  ShowTCur.set(1)
9687  else:
9688  ShowTCur.set(0)
9689 #
9690 def onCanvasShowVcur(event):
9691  global ShowVCur
9692 
9693  if ShowVCur.get() == 0:
9694  ShowVCur.set(1)
9695  else:
9696  ShowVCur.set(0)
9697 #
9699  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
9700 
9701  XCursor = event.x
9702  YCursor = event.y
9703  if RUNstatus.get() == 0:
9704  UpdateXYScreen()
9705  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
9706 #
9708  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
9709  if event.widget == XYca:
9710  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
9711  ShiftKeyDwn = event.state & 1
9712  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
9713  # respond to Linux or Windows wheel event
9714  if event.num == 5 or event.delta == -120:
9715  XCursor -= 1
9716  if event.num == 4 or event.delta == 120:
9717  XCursor += 1
9718  # XCursor = XCursor + event.delta/100
9719  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
9720  # respond to Linux or Windows wheel event
9721  if event.num == 5 or event.delta == -120:
9722  YCursor += 1
9723  if event.num == 4 or event.delta == 120:
9724  YCursor -= 1
9725  #YCursor = YCursor - event.delta/100
9726  if RUNstatus.get() == 0:
9727  UpdateXYScreen()
9728 #
9730  global X0LXY # Left top X value
9731  global Y0TXY # Left top Y value
9732  global GRWXY # Screenwidth
9733  global GRHXY # Screenheight
9734  global FontSize
9735  global XYca
9736  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9737  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
9738  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
9739  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
9740  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9741  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9742  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9743  # add markers only if stopped
9744  #
9745  if (RUNstatus.get() == 0):
9746  MarkerNum = MarkerNum + 1
9747  try:
9748  CH1pdvRange = float(eval(CHAsbxy.get()))
9749  except:
9750  CHAsbxy.delete(0,END)
9751  CHAsbxy.insert(0, CH1pdvRange)
9752  try:
9753  CH2pdvRange = float(eval(CHBsbxy.get()))
9754  except:
9755  CHBsb.delete(0,END)
9756  CHBsb.insert(0, CH2pdvRange)
9757  try:
9758  CH1IpdvRange = float(eval(CHAIsbxy.get()))
9759  except:
9760  CHAIsbxy.delete(0,END)
9761  CHAIsbxy.insert(0, CH1IpdvRange)
9762  try:
9763  CH2IpdvRange = float(eval(CHBIsbxy.get()))
9764  except:
9765  CHBIsbxy.delete(0,END)
9766  CHBIsbxy.insert(0, CH2IpdvRange)
9767  # get the vertical offsets
9768  try:
9769  CHAOffset = float(eval(CHAVPosEntryxy.get()))
9770  except:
9771  CHAVPosEntryxy.delete(0,END)
9772  CHAVPosEntryxy.insert(0, CHAOffset)
9773  try:
9774  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
9775  except:
9776  CHAIPosEntryxy.delete(0,END)
9777  CHAIPosEntryxy.insert(0, CHAIOffset)
9778  try:
9779  CHBOffset = float(eval(CHBVPosEntryxy.get()))
9780  except:
9781  CHBVPosEntryxy.delete(0,END)
9782  CHBVPosEntryxy.insert(0, CHBOffset)
9783  try:
9784  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
9785  except:
9786  CHBIPosEntryxy.delete(0,END)
9787  CHBIPosEntryxy.insert(0, CHBIOffset)
9788  # prevent divide by zero error
9789  if CH1pdvRange < 0.001:
9790  CH1pdvRange = 0.001
9791  if CH2pdvRange < 0.001:
9792  CH2pdvRange = 0.001
9793  if CH1IpdvRange < 1.0:
9794  CH1IpdvRange = 1.0
9795  if CH2IpdvRange < 1.0:
9796  CH2IpdvRange = 1.0
9797  try:
9798  HoldOff = float(eval(HoldOffentry.get()))
9799  if HoldOff < 0:
9800  HoldOff = 0
9801  except:
9802  HoldOffentry.delete(0,END)
9803  HoldOffentry.insert(0, HoldOff)
9804  #
9805  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
9806  Xconv1 = float(GRWXY/10) / CH1pdvRange
9807  Yconv2 = float(GRHXY/10) / CH2pdvRange
9808  Xconv2 = float(GRWXY/10) / CH2pdvRange
9809  YIconv1 = float(GRHXY/10) / CH1IpdvRange
9810  YIconv2 = float(GRHXY/10) / CH2IpdvRange
9811  COLORmarker = COLORtext
9812  Yoffset1 = CHAOffset
9813  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
9814  xc1 = GRWXY / 2 + X0LXY
9815  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
9816  # draw X at marker point and number
9817  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9818  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9819  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
9820  V_label = str(MarkerNum) + " "
9821  x = X0LXY + 5
9822  y = Y0TXY + 3 + (MarkerNum*10)
9823  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset # preset the variable
9824  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
9825  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
9826  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9827  VyString = ' {0:.3f} '.format(-yvolts)
9828  VxString = ' {0:.3f} '.format(-xvolts)
9829  V_label = V_label + VxString + " V, " + VyString + " V"
9830  if MarkerNum > 1:
9831  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
9832  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9833  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
9834  PrevY = yvolts
9835  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
9836  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
9837  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9838  VyString = ' {0:.3f} '.format(-yvolts)
9839  VxString = ' {0:.3f} '.format(-xvolts)
9840  V_label = V_label + VxString + " V, " + VyString + " V"
9841  if MarkerNum > 1:
9842  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
9843  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9844  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
9845  PrevY = yvolts
9846  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
9847  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9848  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
9849  VxString = ' {0:.3f} '.format(-xvolts)
9850  VyString = ' {0:.1f} '.format(-ymA)
9851  V_label = V_label + VxString + " V, " + VyString + " mA"
9852  if MarkerNum > 1:
9853  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9854  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9855  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9856  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9857  V_label = V_label + ", dV/dI " + DeltaR
9858  PrevY = ymA
9859  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
9860  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9861  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
9862  VxString = ' {0:.3f} '.format(-xvolts)
9863  VyString = ' {0:.1f} '.format(-ymA)
9864  V_label = V_label + VxString + " V, " + VyString + " mA"
9865  if MarkerNum > 1:
9866  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9867  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9868  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9869  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9870  V_label = V_label + ", dV/dI " + DeltaR
9871  PrevY = ymA
9872  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
9873  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9874  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
9875  VxString = ' {0:.3f} '.format(-xvolts)
9876  VyString = ' {0:.1f} '.format(-ymA)
9877  V_label = V_label + VxString + " V, " + VyString + " mA"
9878  if MarkerNum > 1:
9879  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9880  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9881  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9882  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9883  V_label = V_label + ", dV/dI " + DeltaR
9884  PrevY = ymA
9885  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
9886  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9887  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
9888  VxString = ' {0:.3f} '.format(-xvolts)
9889  VyString = ' {0:.1f} '.format(-ymA)
9890  V_label = V_label + VxString + " V, " + VyString + " mA"
9891  if MarkerNum > 1:
9892  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9893  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9894  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9895  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9896  V_label = V_label + ", dV/dI " + DeltaR
9897  PrevY = ymA
9898  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
9899  PrevX = xvolts
9900 #
9901 # Some DSP functions
9902 #
9903 # Generate Time-series From Half-spectrum code block
9904 # takes: a desired noise spectral density array (freq)
9905 # the sample rate of the time series (fs),
9906 # returns a time series of voltage samples that can be sent to the AWG
9907 #
9908 # DC in first element.
9909 # Output length is 2x input length
9910 def time_points_from_freq(freq, fs=1, density=False):
9911  N=len(freq)
9912  rnd_ph_pos = (numpy.ones(N-1, dtype=numpy.complex)*
9913  numpy.exp(1j*numpy.random.uniform
9914  (0.0,2.0*numpy.pi, N-1)))
9915  rnd_ph_neg = numpy.flip(numpy.conjugate(rnd_ph_pos))
9916  rnd_ph_full = numpy.concatenate(([1],rnd_ph_pos,[1], rnd_ph_neg))
9917  r_s_full = numpy.concatenate((freq, numpy.roll(numpy.flip(freq), 1)))
9918  r_spectrum_rnd_ph = r_s_full * rnd_ph_full
9919  r_time_full = numpy.fft.ifft(r_spectrum_rnd_ph)
9920 # print("RMS imaginary component: ",
9921 # np.std(np.imag(r_time_full)),
9922 # " Should be close to nothing")
9923  if (density == True):
9924  #Note that this N is "predivided" by 2
9925  r_time_full *= N*numpy.sqrt(fs/(N))
9926  return(numpy.real(r_time_full))
9927 #
9928 def TimeSeriesNoise(n, Fsample, mag, b=4):
9929  # Build Noise Time-series
9930  # n = number of Freq Bins
9931  # b = number of noise bands
9932  # Fsample is Sample Rate
9933  # generates four "bands" of mag V/rootHz noise
9934  mag = mag * 0.707106 # scale by 1/sqrt 2 for RMS
9935  width = int(n/(4 * b))
9936  i = 1
9937  aband = numpy.ones(width)
9938  zband = numpy.zeros(width)
9939  bands = numpy.concatenate((aband, zband))
9940  while i < b:
9941  bands = numpy.concatenate((bands, aband, zband))
9942  i = i + 1
9943  bands = bands*mag
9944  bands[0] = 0.0 # Set DC bin content to zero
9945  return time_points_from_freq(bands, fs=Fsample, density=True)
9946 #
9947 # Generate Time samples for single frequency Bin
9948 # Uses IFFT
9949 #
9950 def TimeSeriesSingleTone(n, BinNum, Fsample, mag):
9951  # Build Single tone Time-series
9952  # n = number of Freq Bins
9953  # BinNum = FFT Bin number
9954  # Fsample is Sample Rate
9955  # mag is tone amplitude
9956  bands = numpy.zeros(n)
9957  bands[BinNum] = 1
9958  bands = bands * (mag/2.0)
9959  return time_points_from_freq(bands, fs=Fsample, density=True)
9960 #
9961 def PinkNoise(N, mag):
9962  # Pink noise.
9963  # Pink noise has equal power in bands that are proportionally wide.
9964  # Power spectral density decreases with 3 dB per octave.
9965  # N Length of sample array, mag magnitude scaling factor
9966 
9967  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
9968  X = numpy.fft.rfft(x) / N
9969  S = numpy.sqrt(numpy.arange(X.size)+1.0) # +1 to avoid divide by zero
9970  y = numpy.fft.irfft(X/S).real[:N] # extremely tiny value 1e-9 without normalization
9971  z = numpy.ndarray = mag
9972  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
9973 
9974  return y
9975 #
9976 def BlueNoise(N, mag):
9977  # Blue noise.
9978  # Power increases with 6 dB per octave.
9979  # Power spectral density increases with 3 dB per octave.
9980  # N Length of sample array, mag magnitude scaling factor
9981 
9982  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
9983  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
9984  X = numpy.fft.rfft(x) / N
9985  S = numpy.sqrt(numpy.arange(X.size)) # Filter
9986  y = numpy.fft.irfft(X*S).real[:N]
9987  z = numpy.ndarray = mag
9988  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
9989 
9990  return y
9991 #
9992 def BrownNoise(N, mag):
9993  # Brown noise.
9994  # Power decreases with -3 dB per octave.
9995  # Power spectral density decreases with 6 dB per octave.
9996  # N Length of sample array, mag magnitude scaling factor
9997 
9998  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
9999  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10000  X = numpy.fft.rfft(x) / N
10001  S = numpy.arange(X.size)+1 # Filter
10002  y = numpy.fft.irfft(X/S).real[:N]
10003  z = numpy.ndarray = mag
10004  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10005 
10006  return y
10007 #
10008 def VioletNoise(N, mag):
10009  # Violet noise.
10010  # Power increases with +9 dB per octave.
10011  # Power density increases with +6 dB per octave.
10012  # N Length of sample array, mag magnitude scaling factor
10013 
10014  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10015  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10016  X = numpy.fft.rfft(x) / N
10017  S = numpy.arange(X.size) # Filter
10018  y = numpy.fft.irfft(X*S).real[0:N]
10019  z = numpy.ndarray = mag
10020  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10021 
10022  return y
10023 #
10024 def SchroederPhase(Length, NrTones, Ampl):
10025  # Generate a Schroeder Phase (Chirp) of Length samples and having NrTones
10026  OutArray = []
10027  OutArray = Ampl*numpy.cos(numpy.linspace(0, 2*numpy.pi, Length)) # the fundamental
10028  k = 2
10029  while k <= NrTones:
10030  # Add all harmonics up to NrTones
10031  Harmonic = Ampl*numpy.cos(numpy.linspace(0, k*2*numpy.pi, Length)+(numpy.pi*k*k/NrTones))
10032  OutArray = OutArray + Harmonic
10033  k = k + 1
10034  OutArray = OutArray + 2.5 # Center wavefrom on 2.5 V
10035  return(OutArray)
10036 #
10037 def Wrap(InArray, WrFactor):
10038  # Build new array by skipping WrFactor samples and wrapping back around
10039  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
10040  # effectively multiplies the frequency content by WrFactor
10041  OutArray = []
10042  OutArray = numpy.array(OutArray)
10043  InArray = numpy.array(InArray)
10044  EndIndex = len(InArray)
10045  StartIndex = 0
10046  while StartIndex < WrFactor:
10047  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
10048  StartIndex = StartIndex + 1
10049  return OutArray
10050 #
10051 def UnWrap(InArray, WrFactor):
10052  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
10053  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
10054  # effectively divided the frequency content by WrFactor
10055  OutArray = []
10056  InArray = numpy.array(InArray)
10057  EndIndex = int(len(InArray)/WrFactor)
10058  StartIndex = 0
10059  while StartIndex < EndIndex:
10060  LoopIndex = 0
10061  while LoopIndex < WrFactor:
10062  OutArray.append(InArray[StartIndex+LoopIndex])
10063  LoopIndex = LoopIndex + 1
10064  StartIndex = StartIndex + 1
10065  OutArray = numpy.array(OutArray)
10066  return OutArray
10067 #
10068 def Write_WAV(data, repeat, filename):
10069  global SAMPLErate
10070  # write data array to mono .wav file 100KSPS
10071  # copy buffer repeat times in output file
10072  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
10073  wavfile = wave.open(filename, "w")
10074  nchannels = 1
10075  sampwidth = 2
10076  framerate = SAMPLErate
10077  amplitude = 32766
10078  nframes = len(data)
10079  comptype = "NONE"
10080  compname = "not compressed"
10081  wavfile.setparams((nchannels,
10082  sampwidth,
10083  framerate,
10084  nframes,
10085  comptype,
10086  compname))
10087  # Normalize data
10088  ArrN = numpy.array(data)
10089  ArrN /= numpy.max(numpy.abs(data))
10090  frames = []
10091  for s in ArrN:
10092  mul = int(s * amplitude)
10093  # print "s: %f mul: %d" % (s, mul)
10094  frames.append(struct.pack('h', mul))
10095  print( len(frames))
10096  frames = ''.join(frames)
10097  print( len(frames))
10098  for x in xrange(0, repeat):
10099  print( x )
10100  wavfile.writeframes(frames)
10101  wavfile.close()
10102 
10103 # =========== Awg functions ==================
10104 def BAWGAAmpl(temp):
10105  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10106  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10107 
10108  try:
10109  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
10110  except:
10111  AWGAAmplEntry.delete(0,"end")
10112  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10113  #
10114  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10115  if AWGAMode.get() == 0: # Source Voltage measure current mode
10116  if AWGAAmplvalue > 5.00:
10117  AWGAAmplvalue = 5.00
10118  AWGAAmplEntry.delete(0,"end")
10119  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10120  if AWGAAmplvalue < 0.00:
10121  AWGAAmplvalue = 0.00
10122  AWGAAmplEntry.delete(0,"end")
10123  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10124  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10125  if AWGAMode.get() == 0: # Source Voltage measure current mode
10126  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
10127  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
10128  AWGAAmplEntry.delete(0,"end")
10129  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10130  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
10131  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
10132  AWGAAmplEntry.delete(0,"end")
10133  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10134  if AWGAMode.get() == 1: # Source current measure voltage mode
10135  if AWGAAmplvalue > 200.00:
10136  AWGAAmplvalue = 200.00
10137  AWGAAmplEntry.delete(0,"end")
10138  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10139  if AWGAAmplvalue < -200.00:
10140  AWGAAmplvalue = -200.00
10141  AWGAAmplEntry.delete(0,"end")
10142  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10143 #
10144 def BAWGAOffset(temp):
10145  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10146  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10147 
10148  try:
10149  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
10150  except:
10151  AWGAOffsetEntry.delete(0,"end")
10152  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10153  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10154  if AWGAMode.get() == 0: # Source Voltage measure current mode
10155  if AWGAOffsetvalue > 5.00:
10156  AWGAOffsetvalue = 5.00
10157  AWGAOffsetEntry.delete(0,"end")
10158  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10159  if AWGAOffsetvalue < 0.00:
10160  AWGAOffsetvalue = 0.00
10161  AWGAOffsetEntry.delete(0,"end")
10162  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10163  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10164  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
10165  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
10166  AWGAOffsetEntry.delete(0,"end")
10167  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10168  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
10169  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
10170  AWGAOffsetEntry.delete(0,"end")
10171  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10172  if AWGAMode.get() == 1: # Source current measure voltage mode
10173  if AWGAOffsetvalue > 200.00:
10174  AWGAOffsetvalue = 200.00
10175  AWGAOffsetEntry.delete(0,"end")
10176  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10177  if AWGAOffsetvalue < -200.00:
10178  AWGAOffsetvalue = -200.00
10179  AWGAOffsetEntry.delete(0,"end")
10180  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10181 #
10182 def BAWGAFreq(temp):
10183  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
10184  global BodeScreenStatus, BodeDisp, AWGRecLength
10185 
10186  try:
10187  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
10188  except:
10189  AWGAFreqEntry.delete(0,"end")
10190  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10191  if AWG_2X.get() == 1:
10192  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
10193  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
10194  AWGAFreqvalue = 90000
10195  AWGAFreqEntry.delete(0,"end")
10196  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10197  else:
10198  if AWGAFreqvalue > 50000: # max freq is 50KHz
10199  AWGAFreqvalue = 50000
10200  AWGAFreqEntry.delete(0,"end")
10201  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10202  else:
10203  if AWGAFreqvalue > 25000: # max freq is 25KHz
10204  AWGAFreqvalue = 25000
10205  AWGAFreqEntry.delete(0,"end")
10206  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10207  if AWGAFreqvalue < 4.0:
10208  AWGRecLength = 32768*2
10209  else:
10210  AWGRecLength = 32768
10211  if AWGAFreqvalue < 0: # Set negative frequency entry to 10
10212  AWGAFreqvalue = 10
10213  AWGAFreqEntry.delete(0,"end")
10214  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10215  #UpdateAWGA()
10216 
10218  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10219 
10220  if AWGAPhaseDelay.get() == 1:
10221  AWGAPhaseDelay.set(0)
10222  awgaph.configure(text="Phase")
10223  phasealab.configure(text="Deg")
10224  elif AWGAPhaseDelay.get() == 0:
10225  AWGAPhaseDelay.set(1)
10226  awgaph.configure(text="Delay")
10227  phasealab.configure(text="mSec")
10228 
10230  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10231 
10232  if AWGAPhaseDelay.get() == 0:
10233  phasealab.configure(text="Deg")
10234  awgaph.configure(text="Phase")
10235  elif AWGAPhaseDelay.get() == 1:
10236  phasealab.configure(text="mSec")
10237  awgaph.configure(text="Delay")
10238 
10239 def BAWGAPhase(temp):
10240  global AWGAPhaseEntry, AWGAPhasevalue
10241 
10242  try:
10243  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
10244  except:
10245  AWGAPhaseEntry.delete(0,"end")
10246  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10247 
10248  if AWGAPhasevalue > 360: # max phase is 360 degrees
10249  AWGAPhasevalue = 360
10250  AWGAPhaseEntry.delete(0,"end")
10251  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10252  if AWGAPhasevalue < 0: # min phase is 0 degrees
10253  AWGAPhasevalue = 0
10254  AWGAPhaseEntry.delete(0,"end")
10255  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10256 
10257 def BAWGADutyCycle(temp):
10258  global AWGADutyCycleEntry, AWGADutyCyclevalue
10259 
10260  try:
10261  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
10262  except:
10263  AWGADutyCycleEntry.delete(0,"end")
10264  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10265 
10266  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
10267  AWGADutyCyclevalue = 1
10268  AWGADutyCycleEntry.delete(0,"end")
10269  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
10270  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
10271  AWGADutyCyclevalue = 0
10272  AWGADutyCycleEntry.delete(0,"end")
10273  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10274  #UpdateAWGA()
10275 
10277  global AWGAShape, AWGAWave, phasealab, duty1lab
10278 
10279  if AWGAShape.get() == 0:
10280  AWGAWave = 'dc'
10281  duty1lab.config(text="%")
10282  BAWGAPhaseDelay()
10283  if AWGAShape.get() == 1:
10284  AWGAWave = 'sine'
10285  duty1lab.config(text="%")
10286  BAWGAPhaseDelay()
10287  if AWGAShape.get() == 2:
10288  AWGAWave = 'triangle'
10289  duty1lab.config(text="%")
10290  BAWGAPhaseDelay()
10291  if AWGAShape.get() == 3:
10292  AWGAWave = 'sawtooth'
10293  duty1lab.config(text="%")
10294  BAWGAPhaseDelay()
10295  if AWGAShape.get() == 4:
10296  AWGAWave = 'square'
10297  duty1lab.config(text="%")
10298  BAWGAPhaseDelay()
10299  if AWGAShape.get() == 5:
10300  AWGAWave = 'stairstep'
10301  duty1lab.config(text="%")
10302  BAWGAPhaseDelay()
10303  if AWGAShape.get() > 5:
10304  AWGAWave = 'arbitrary'
10305  # UpdateAWGA()
10306 
10308  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile
10309 
10310  # Read values from CVS file
10311  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10312  AWGAcsvFile = filename
10313  AWGALoadCSV()
10314 #
10316  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile, AWGAOffsetvalue
10317 
10318  BAWGAOffset(0)
10319  try:
10320  CSVFile = open(AWGAcsvFile)
10321  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
10322  CSVFile.seek(0)
10323  #csv_f = csv.reader(CSVFile, dialect)
10324  csv_f = csv.reader(CSVFile, csv.excel)
10325  except:
10326  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10327  # print csv_f.dialect
10328  AWGAwaveform = []
10329  ColumnNum = 0
10330  ColumnSel = 0
10331  RowNum = 0
10332  for row in csv_f:
10333  # print 'found row = ', row
10334  if len(row) > 1 and ColumnSel == 0:
10335  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
10336  ColumnNum = int(RequestColumn) - 1
10337  ColumnLen = str(len(row))
10338  ColumnSel = 1
10339  try:
10340  colnum = 0
10341  for col in row:
10342  if colnum == ColumnNum:
10343  AWGAwaveform.append(float(col))
10344  colnum += 1
10345  except:
10346  print( 'skipping non-numeric row', RowNum)
10347  RowNum += 1
10348  AWGAwaveform = numpy.array(AWGAwaveform)
10349  AWGAwaveform = AWGAwaveform + AWGAOffsetvalue # add DC offset from Max entry
10351  CSVFile.close()
10352  UpdateAwgCont()
10353 
10354 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
10356  global AWG_2X, AWGA2X, AWGAwaveform
10357  global AWGFiltA, AWGFiltACoef
10358 
10359  # check if AWG digital filter box checked
10360  if AWGFiltA.get() == 1:
10361  BufLen = len(AWGAwaveform)
10362  CoefLen = len(AWGFiltACoef)/2
10363  AWGAwaveform = numpy.pad(AWGAwaveform, (CoefLen,CoefLen), 'wrap')
10364  AWGAwaveform = numpy.convolve(AWGAwaveform, AWGFiltACoef)
10365  AWGAwaveform = numpy.roll(AWGAwaveform, -CoefLen)
10366  AWGAwaveform = AWGAwaveform[CoefLen:BufLen+CoefLen]
10367 
10368  if AWG_2X.get() == 1:
10369  Tempwaveform = []
10370  AWGA2X = []
10371  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
10372  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
10373  AWGAwaveform = Tempwaveform
10374 #
10376  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10377 
10378  if AWGABurstFlag.get() == 1:
10379  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
10380  if (AWGACyclesString == None): # If Cancel pressed, then None
10381  return
10382  AWGACycles = int(AWGACyclesString)
10383  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
10384  if (AWGADelayString == None): # If Cancel pressed, then None
10385  return
10386  AWGABurstDelay = float(AWGADelayString)
10387  ReMakeAWGwaves()
10388 #
10390  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10391  global AWG_2X, AWGA2X, AWGAwavFile
10392 
10393 # Read values from WAV file
10394  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10395  AWGAwavFile = filename
10396  AWGALoadWAV()
10397 #
10399  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10400  global AWG_2X, AWGA2X, AWGAwavFile
10401 
10402  try:
10403  spf = wave.open(AWGAwavFile,'r')
10404  except:
10405  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10406  AWGAwaveform = []
10407  AWGBwaveform = []
10408  Length = spf.getnframes()
10409  if Length > 90000:
10410  Length = 90000
10411  # If Stereo put first channel in AWGA and second channel in AWGB
10412  if spf.getnchannels() == 2:
10413  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
10414  signal = spf.readframes(Length)
10415  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
10416  n = 0
10417  while n < Length*2:
10418  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10419  n = n + 1
10420  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10421  n = n + 1
10422  AWGAwaveform = numpy.array(AWGAwaveform)
10423  AWGBwaveform = numpy.array(AWGBwaveform)
10424  AWGBShape.set(AWGAShape.get())
10425  else:
10426  #Extract Raw Audio from Wav File
10427  signal = spf.readframes(Length)
10428  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
10429  # offset and scale for 0 5 V range
10430  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
10431  AWGAwaveform = numpy.array(AWGAwaveform)
10433  spf.close()
10434  UpdateAwgCont()
10435 
10437  global AWGAwaveform, AWGALength, awgwindow
10438 
10439  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10440  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
10441 
10443  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10444  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10445  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10446  global DFiltACoef, DFiltBCoef, AWGAShapeLabel, AWGALength
10447  global AWG_2X, AWGA2X
10448 
10449  TempString = AWGAMathString
10450  AWGAShapeLabel.config(text = "Math" ) # change displayed value
10451  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
10452  if (AWGAMathString == None): # If Cancel pressed, then None
10453  AWGAMathString = TempString
10454  return
10455  try:
10456  AWGAwaveform = eval(AWGAMathString)
10457  except:
10458  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
10459  AWGAwaveform = numpy.array(AWGAwaveform)
10461  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
10462  UpdateAwgCont()
10463 #
10465  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10466  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10467  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10468  global DFiltACoef, DFiltBCoef, AWGAShapeLabel
10469  global AWG_2X, AWGA2X
10470 
10471  AWGAwaveform = eval(AWGAMathString)
10472  AWGAwaveform = numpy.array(AWGAwaveform)
10474  UpdateAwgCont()
10475 #
10477  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10478  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10479  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode, AWGRecLength
10480  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10481 
10482  BAWGAAmpl(0)
10483  BAWGAOffset(0)
10484  BAWGAFreq(0)
10485  BAWGAPhase(0)
10486  BAWGADutyCycle(0)
10487 
10488  if AWGAFreqvalue < 1.53: # if frequency is less than 1.53 Hz use libsmu sine function
10489  AWGAShape.set(1)
10490  BAWGAShape()
10491  UpdateAwgCont()
10492  return
10493 
10494  if AWGAFreqvalue > 0.0:
10495  if AWG_2X.get() == 1:
10496  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10497  else:
10498  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10499  else:
10500  AWGAperiodvalue = 10.0
10501 
10502  if AWGAPhaseDelay.get() == 0:
10503  if AWGAPhasevalue > 0:
10504  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10505  else:
10506  AWGAdelayvalue = 0.0
10507  elif AWGAPhaseDelay.get() == 1:
10508  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10509  Cycles = int(AWGRecLength/AWGAperiodvalue)
10510  if Cycles < 1:
10511  Cycles = 1
10512  RecLength = int(Cycles * AWGAperiodvalue)
10513  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10514  RecLength = RecLength + 1
10515  AWGAwaveform = []
10516  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
10517 
10518  if AWG_Amp_Mode.get() == 0:
10519  if AWGAMode.get() == 1: # convert to mA
10520  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10521  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10522  else:
10523  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10524  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10525  else:
10526  if AWGAMode.get() == 1: # convert to mA
10527  amplitude = AWGAAmplvalue/1000.0
10528  offset = AWGAOffsetvalue/1000.0
10529  else:
10530  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10531  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10532  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10533  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10534 #
10536  BAWGAPhaseDelay()
10537  duty1lab.config(text="%")
10538  UpdateAwgCont()
10539 #
10541  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10542  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10543  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
10544  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
10545 
10546  BAWGAAmpl(0)
10547  BAWGAOffset(0)
10548  BAWGAFreq(0)
10549 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
10550  duty1lab.config(text = "M Index")
10551  phasealab.config(text = "M Freq")
10552 
10553  if AWGAFreqvalue > 0.0:
10554  if AWG_2X.get() == 1:
10555  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10556  else:
10557  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10558  else:
10559  AWGAperiodvalue = 10.0
10560 
10561  try:
10562  ModFreq = float(eval(AWGAPhaseEntry.get()))
10563  except:
10564  ModFreq = 10
10565  AWGAPhaseEntry.delete(0,"end")
10566  AWGAPhaseEntry.insert(0, ModFreq)
10567 
10568  if ModFreq < 10:
10569  ModFreq = 10
10570  AWGAPhaseEntry.delete(0,"end")
10571  AWGAPhaseEntry.insert(0, ModFreq)
10572 
10573  if AWG_2X.get() == 1:
10574  MODperiodvalue = (BaseSampleRate*2)/ModFreq
10575  else:
10576  MODperiodvalue = BaseSampleRate/ModFreq
10577 
10578  try:
10579  ModIndex = float(eval(AWGADutyCycleEntry.get()))
10580  except:
10581  ModIndex = 1.0
10582  AWGADutyCycleEntry.delete(0,"end")
10583  AWGADutyCycleEntry.insert(0, ModIndex)
10584 
10585  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
10586  if ModCycles < 1:
10587  ModCycles = 1
10588  RecLength = int(ModCycles * MODperiodvalue)
10589  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10590  RecLength = RecLength + 1
10591  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
10592  AWGAwaveform = []
10593  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
10594  if AWG_Amp_Mode.get() == 0:
10595  if AWGAMode.get() == 1: # convert to mA
10596  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10597  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10598  else:
10599  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10600  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10601  else:
10602  if AWGAMode.get() == 1: # convert to mA
10603  amplitude = AWGAAmplvalue/1000.0
10604  offset = AWGAOffsetvalue/1000.0
10605  else:
10606  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10607  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10608  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10609  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10610 #
10611  SplitAWGAwaveform() # if needed
10612  UpdateAwgCont()
10613 #
10615  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10616  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10617  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
10618  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
10619 
10620  BAWGAAmpl(0)
10621  BAWGAOffset(0)
10622  BAWGAFreq(0)
10623 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
10624  duty1lab.config(text = "M Index")
10625  phasealab.config(text = "M Freq")
10626 
10627  if AWGAFreqvalue > 0.0:
10628  if AWG_2X.get() == 1:
10629  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10630  else:
10631  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10632  else:
10633  AWGAperiodvalue = 10.0
10634 
10635  try:
10636  ModFreq = float(eval(AWGAPhaseEntry.get()))
10637  except:
10638  ModFreq = 10
10639  AWGAPhaseEntry.delete(0,"end")
10640  AWGAPhaseEntry.insert(0, ModFreq)
10641 
10642  if ModFreq < 10:
10643  ModFreq = 10
10644  AWGAPhaseEntry.delete(0,"end")
10645  AWGAPhaseEntry.insert(0, ModFreq)
10646 
10647  if AWG_2X.get() == 1:
10648  MODperiodvalue = (BaseSampleRate*2)/ModFreq
10649  else:
10650  MODperiodvalue = BaseSampleRate/ModFreq
10651 
10652  try:
10653  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
10654  except:
10655  ModIndex = 50.0
10656  AWGADutyCycleEntry.delete(0,"end")
10657  AWGADutyCycleEntry.insert(0, ModIndex)
10658 
10659  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
10660  if ModCycles < 1:
10661  ModCycles = 1
10662  RecLength = int(ModCycles * MODperiodvalue)
10663  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10664  RecLength = RecLength + 1
10665  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
10666  AWGAwaveform = []
10667  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
10668  if AWG_Amp_Mode.get() == 0:
10669  if AWGAMode.get() == 1: # convert to mA
10670  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10671  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10672  else:
10673  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10674  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10675  else:
10676  if AWGAMode.get() == 1: # convert to mA
10677  amplitude = AWGAAmplvalue/1000.0
10678  offset = AWGAOffsetvalue/1000.0
10679  else:
10680  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10681  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10682  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10683  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10684 #
10685  SplitAWGAwaveform() # if needed
10686  UpdateAwgCont()
10687 #
10689  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
10690  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10691  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10692  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10693 
10694  BAWGAAmpl(0)
10695  BAWGAOffset(0)
10696  BAWGAFreq(0)
10697  BAWGAPhase(0)
10698  BAWGADutyCycle(0)
10699 
10700  if AWGAFreqvalue > 0.0:
10701  if AWG_2X.get() == 1:
10702  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10703  else:
10704  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10705  else:
10706  AWGAperiodvalue = 0.0
10707  if AWG_Amp_Mode.get() == 1:
10708  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10709  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10710  else:
10711  MaxV = AWGAOffsetvalue
10712  MinV = AWGAAmplvalue
10713 
10714  PulseWidth = int(AWGADutyCyclevalue*100)
10715  PulseSamples = int(AWGAperiodvalue/PulseWidth)
10716  AWGAwaveform = []
10717  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
10718  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
10719  # print(v)
10720  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
10721  if j >= v:
10722  AWGAwaveform.append(MaxV) # j>=v?1:0
10723  else:
10724  AWGAwaveform.append(MinV) # j>=v?1:0
10726  duty1lab.config(text="PWidth")
10727  UpdateAwgCont()
10728 #
10730  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
10731  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10732  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10733  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10734 
10735  BAWGAAmpl(0)
10736  BAWGAOffset(0)
10737  BAWGAFreq(0)
10738  BAWGADutyCycle(0)
10739 
10740  Max_term = int(AWGADutyCyclevalue*100)
10741  if AWG_2X.get() == 1:
10742  TempRate = (BaseSampleRate*2)
10743  else:
10744  TempRate = BaseSampleRate
10745  AWGAwaveform = []
10746  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGAFreqvalue))) # the fundamental
10747  k = 3
10748  while k <= Max_term:
10749  # Add odd harmonics up to max_term
10750  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGAFreqvalue))))
10751  AWGAwaveform = AWGAwaveform + Harmonic
10752  k = k + 2 # skip even numbers
10753  if AWG_Amp_Mode.get() == 0:
10754  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
10755  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
10756  else:
10757  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10758  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10759  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10761  duty1lab.config(text="Harmonics")
10762  BAWGAPhaseDelay()
10763  UpdateAwgCont()
10764 #
10766  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10767  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
10768  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10769  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10770 
10771  BAWGAAmpl(0)
10772  BAWGAOffset(0)
10773  BAWGAFreq(0)
10774  BAWGAPhase(0)
10775  BAWGADutyCycle(0)
10776 
10777  if AWGAFreqvalue > 0.0:
10778  if AWG_2X.get() == 1:
10779  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10780  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10781  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10782  AWGAperiodvalue = AWGAperiodvalue + 1
10783  else:
10784  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10785  SamplesPermS = int(BaseSampleRate/1000) # 100
10786  else:
10787  AWGAperiodvalue = 0.0
10788  if AWG_Amp_Mode.get() == 1:
10789  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10790  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10791  else:
10792  MaxV = AWGAOffsetvalue
10793  MinV = AWGAAmplvalue
10794 
10795  if AWGAPhaseDelay.get() == 0:
10796  if AWGAPhasevalue > 0:
10797  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10798  else:
10799  AWGAdelayvalue = 0.0
10800  elif AWGAPhaseDelay.get() == 1:
10801  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10802 
10803  Cycles = int(AWGADutyCyclevalue*100)
10804  NCycles = -1 * Cycles
10805  AWGAwaveform = []
10806  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGAFreqvalue)))
10807  amplitude = (MaxV-MinV) / 2.0
10808  offset = (MaxV+MinV) / 2.0
10809  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10810  Cycles = int(37500/AWGAperiodvalue)
10811  if Cycles < 1:
10812  Cycles = 1
10813  if Cycles > 1:
10814  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
10815  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
10816  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10818  #BAWGAPhaseDelay()
10819  duty1lab.config(text="Cycles")
10820  BAWGAPhaseDelay()
10821  UpdateAwgCont()
10822 #
10824  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10825  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10826  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10827  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10828  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10829 
10830  BAWGAAmpl(0)
10831  BAWGAOffset(0)
10832  BAWGAFreq(0)
10833  BAWGAPhase(0)
10834  BAWGADutyCycle(0)
10835 
10836  if AWGAFreqvalue > 0.0:
10837  if AWG_2X.get() == 1:
10838  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10839  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10840  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10841  AWGAperiodvalue = AWGAperiodvalue + 1
10842  else:
10843  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10844  SamplesPermS = int(BaseSampleRate/1000) # 100
10845  else:
10846  AWGAperiodvalue = 0.0
10847  if AWG_Amp_Mode.get() == 1:
10848  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10849  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10850  else:
10851  MaxV = AWGAOffsetvalue
10852  MinV = AWGAAmplvalue
10853  AWGAwaveform = []
10854  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
10855  if SlopeValue <= 0:
10856  SlopeValue = 1
10857  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
10858  if PulseWidth <=0:
10859  PulseWidth = 1
10860  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
10861  if Remainder <= 0:
10862  Remainder = 1
10863  PulseWidth = PulseWidth - SlopeValue
10864  if PulseWidth <=0:
10865  PulseWidth = 1
10866  StepAmp = (MaxV - MinV)/2
10867  StepOff = (MaxV + MinV)/2
10868  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10869  MidArray = numpy.ones(PulseWidth) * MinV
10870  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
10871  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
10872  if AWGABurstFlag.get() == 1:
10873  TempOneCycle = AWGAwaveform
10874  for i in range(AWGACycles-1):
10875  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10876  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
10877  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
10879  duty1lab.config(text="%")
10880  phasealab.config(text = "Rise Time")
10881  UpdateAwgCont()
10882 #
10884  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10885  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10886  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10887  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10888  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10889 
10890  BAWGAAmpl(0)
10891  BAWGAOffset(0)
10892  BAWGAFreq(0)
10893  BAWGAPhase(0)
10894  BAWGADutyCycle(0)
10895 
10896  if AWGAFreqvalue > 0.0:
10897  if AWG_2X.get() == 1:
10898  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10899  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10900  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10901  AWGAperiodvalue = AWGAperiodvalue + 1
10902  else:
10903  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10904  SamplesPermS = int(BaseSampleRate/1000) # 100
10905  else:
10906  AWGAperiodvalue = 0.0
10907  if AWG_Amp_Mode.get() == 1:
10908  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10909  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10910  else:
10911  MaxV = AWGAOffsetvalue
10912  MinV = AWGAAmplvalue
10913  AWGAwaveform = []
10914  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
10915  if SlopeValue <= 0:
10916  SlopeValue = 1
10917  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
10918  if PulseWidth <=0:
10919  PulseWidth = 1
10920  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
10921  if Remainder <= 0:
10922  Remainder = 1
10923  PulseWidth = PulseWidth - SlopeValue
10924  if PulseWidth <=0:
10925  PulseWidth = 1
10926  StepValue = (MaxV - MinV) / SlopeValue
10927  SampleValue = MinV
10928  for i in range(SlopeValue):
10929  AWGAwaveform.append(SampleValue)
10930  SampleValue = SampleValue + StepValue
10931  for i in range(PulseWidth):
10932  AWGAwaveform.append(MaxV)
10933  for i in range(SlopeValue):
10934  AWGAwaveform.append(SampleValue)
10935  SampleValue = SampleValue - StepValue
10936  for i in range(Remainder):
10937  AWGAwaveform.append(MinV)
10938  if AWGABurstFlag.get() == 1:
10939  TempOneCycle = AWGAwaveform
10940  for i in range(AWGACycles-1):
10941  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10942  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
10943  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
10945  duty1lab.config(text="%")
10946  phasealab.config(text = "Rise Time")
10947  UpdateAwgCont()
10948 #
10950  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10951  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10952  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10953  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10954  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10955 
10956  BAWGAAmpl(0)
10957  BAWGAOffset(0)
10958  BAWGAFreq(0)
10959  BAWGAPhase(0)
10960 
10961  try:
10962  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
10963  except:
10964  AWGADutyCycleEntry.delete(0,"end")
10965  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10966 
10967  if AWGAFreqvalue > 0.0:
10968  if AWG_2X.get() == 1:
10969  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10970  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10971  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10972  AWGAperiodvalue = AWGAperiodvalue + 1
10973  else:
10974  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10975  SamplesPermS = int(BaseSampleRate/1000) # 100
10976  else:
10977  AWGAperiodvalue = 0.0
10978  if AWG_Amp_Mode.get() == 1:
10979  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10980  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10981  else:
10982  MaxV = AWGAOffsetvalue
10983  MinV = AWGAAmplvalue
10984  AWGAwaveform = []
10985  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
10986  if SlopeValue <= 0:
10987  SlopeValue = 1
10988  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
10989  if PulseWidth <=0:
10990  PulseWidth = 1
10991  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
10992  if Remainder <= 0:
10993  Remainder = 1
10994  PulseWidth = PulseWidth - SlopeValue
10995  if PulseWidth <=0:
10996  PulseWidth = 1
10997  StepValue = (MaxV - MinV) / SlopeValue
10998  SampleValue = MinV
10999  for i in range(SlopeValue):
11000  AWGAwaveform.append(SampleValue)
11001  SampleValue = SampleValue + StepValue
11002  for i in range(PulseWidth):
11003  AWGAwaveform.append(MaxV)
11004  for i in range(SlopeValue):
11005  AWGAwaveform.append(SampleValue)
11006  SampleValue = SampleValue - StepValue
11007  for i in range(Remainder):
11008  AWGAwaveform.append(MinV)
11009  if AWGABurstFlag.get() == 1:
11010  TempOneCycle = AWGAwaveform
11011  for i in range(AWGACycles-1):
11012  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11013  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11014  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11016  duty1lab.config(text="Width mS")
11017  phasealab.config(text = "Rise Time")
11018  UpdateAwgCont()
11019 #
11021  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11022  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11023  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11024  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11025  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11026 
11027  BAWGAAmpl(0)
11028  BAWGAOffset(0)
11029  BAWGAFreq(0)
11030  BAWGAPhase(0)
11031  BAWGADutyCycle(0)
11032 
11033  if AWGAFreqvalue > 0.0:
11034  if AWG_2X.get() == 1:
11035  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11036  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11037  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11038  AWGAperiodvalue = AWGAperiodvalue + 1
11039  else:
11040  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11041  SamplesPermS = int(BaseSampleRate/1000) # 100
11042  else:
11043  AWGAperiodvalue = 0.0
11044  if AWG_Amp_Mode.get() == 1:
11045  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11046  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11047  else:
11048  MaxV = AWGAOffsetvalue
11049  MinV = AWGAAmplvalue
11050  AWGAwaveform = []
11051  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11052  if SlopeValue <= 0:
11053  SlopeValue = 1
11054  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11055  if PulseWidth <=0:
11056  PulseWidth = 1
11057  Remainder = int(AWGAperiodvalue - PulseWidth)
11058  if Remainder <= 0:
11059  Remainder = 1
11060  PulseWidth = PulseWidth - SlopeValue
11061  if PulseWidth <=0:
11062  PulseWidth = 1
11063  StepValue = (MaxV - MinV) / SlopeValue
11064  SampleValue = MinV
11065  for i in range(SlopeValue):
11066  AWGAwaveform.append(SampleValue)
11067  SampleValue = SampleValue + StepValue
11068  for i in range(PulseWidth):
11069  AWGAwaveform.append(MaxV)
11070  for i in range(Remainder):
11071  AWGAwaveform.append(MinV)
11072  if AWGABurstFlag.get() == 1:
11073  TempOneCycle = AWGAwaveform
11074  for i in range(AWGACycles-1):
11075  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11076  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11077  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11079  duty1lab.config(text="%")
11080  phasealab.config(text = "Slope Time")
11081  UpdateAwgCont()
11082 #
11084  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
11085  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11086  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11087  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11088  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11089 
11090  BAWGAAmpl(0)
11091  BAWGAOffset(0)
11092  BAWGAFreq(0)
11093  BAWGAPhase(0)
11094  BAWGADutyCycle(0)
11095 
11096  if AWGAFreqvalue > 0.0:
11097  if AWG_2X.get() == 1:
11098  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11099  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11100  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11101  AWGAperiodvalue = AWGAperiodvalue + 1
11102  else:
11103  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11104  SamplesPermS = int(BaseSampleRate/1000) # 100
11105  else:
11106  AWGAperiodvalue = 0.0
11107  if AWG_Amp_Mode.get() == 1:
11108  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11109  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11110  else:
11111  MaxV = AWGAOffsetvalue
11112  MinV = AWGAAmplvalue
11113  #
11114  if AWGAPhaseDelay.get() == 0:
11115  if AWGAPhasevalue > 0:
11116  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11117  else:
11118  AWGAdelayvalue = 0.0
11119  elif AWGAPhaseDelay.get() == 1:
11120  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11121  #
11122  AWGAwaveform = []
11123  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11124  if PulseWidth <=0:
11125  PulseWidth = 1
11126  Remainder = int(AWGAperiodvalue - PulseWidth)
11127  if Remainder <= 0:
11128  Remainder = 1
11129  UpStepValue = (MaxV - MinV) / PulseWidth
11130  DownStepValue = (MaxV - MinV) / Remainder
11131  SampleValue = MinV
11132  for i in range(PulseWidth):
11133  AWGAwaveform.append(SampleValue)
11134  SampleValue = SampleValue + UpStepValue
11135  for i in range(Remainder):
11136  AWGAwaveform.append(SampleValue)
11137  SampleValue = SampleValue - DownStepValue
11138  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11139  if AWGABurstFlag.get() == 1:
11140  TempOneCycle = AWGAwaveform
11141  for i in range(AWGACycles-1):
11142  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11143  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11144  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11146  BAWGAPhaseDelay()
11147  duty1lab.config(text = "Symmetry")
11148  BAWGAPhaseDelay()
11149  UpdateAwgCont()
11150 #
11152  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11153  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
11154  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11155  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11156  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11157 
11158  BAWGAAmpl(0)
11159  BAWGAOffset(0)
11160  BAWGAFreq(0)
11161  BAWGAPhase(0)
11162  BAWGADutyCycle(0)
11163 
11164  if AWGAFreqvalue > 0.0:
11165  if AWG_2X.get() == 1:
11166  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11167  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11168  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11169  AWGAperiodvalue = AWGAperiodvalue + 1
11170  else:
11171  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11172  SamplesPermS = int(BaseSampleRate/1000) # 100
11173  else:
11174  AWGAperiodvalue = 0.0
11175  if AWG_Amp_Mode.get() == 1:
11176  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11177  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11178  else:
11179  MaxV = AWGAOffsetvalue
11180  MinV = AWGAAmplvalue
11181  AWGAwaveform = []
11182  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
11183  if AWGAPhaseDelay.get() == 0:
11184  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
11185  elif AWGAPhaseDelay.get() == 1:
11186  DelayValue = int(AWGAPhasevalue*SamplesPermS)
11187  for i in range(DelayValue-PulseWidth):
11188  AWGAwaveform.append((MinV+MaxV)/2.0)
11189  for i in range(PulseWidth):
11190  AWGAwaveform.append(MaxV)
11191  for i in range(PulseWidth):
11192  AWGAwaveform.append(MinV)
11193  DelayValue = int(AWGAperiodvalue-DelayValue)
11194  for i in range(DelayValue-PulseWidth):
11195  AWGAwaveform.append((MinV+MaxV)/2.0)
11196  if AWGABurstFlag.get() == 1:
11197  TempOneCycle = AWGAwaveform
11198  for i in range(AWGACycles-1):
11199  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11200  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11201  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11203  duty1lab.config(text = "Duty Cycle")
11204  BAWGAPhaseDelay()
11205  UpdateAwgCont()
11206 
11208  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11209  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11210  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11211  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11212  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11213 
11214  BAWGAAmpl(0)
11215  BAWGAOffset(0)
11216  BAWGAFreq(0)
11217 
11218  if AWGAFreqvalue > 0.0:
11219  if AWG_2X.get() == 1:
11220  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11221  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11222  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11223  AWGAperiodvalue = AWGAperiodvalue + 1
11224  else:
11225  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11226  SamplesPermS = int(BaseSampleRate/1000) # 100
11227  else:
11228  AWGAperiodvalue = 0.0
11229  if AWG_Amp_Mode.get() == 1:
11230  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11231  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11232  else:
11233  if AWGAAmplvalue > AWGAOffsetvalue:
11234  MinV = AWGAOffsetvalue
11235  MaxV = AWGAAmplvalue
11236  else:
11237  MaxV = AWGAOffsetvalue
11238  MinV = AWGAAmplvalue
11239  AWGAwaveform = []
11240  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
11241  Mid = (MaxV+MinV)/2.0
11242  if AWGABurstFlag.get() == 1:
11243  TempOneCycle = AWGAwaveform
11244  for i in range(AWGACycles-1):
11245  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11246  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11247  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11249  BAWGAPhaseDelay()
11250  UpdateAwgCont()
11251 
11253  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11254  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11255  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11256  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11257  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11258 
11259  BAWGAAmpl(0)
11260  BAWGAOffset(0)
11261  BAWGAFreq(0)
11262 
11263  if AWGAFreqvalue > 0.0:
11264  if AWG_2X.get() == 1:
11265  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11266  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11267  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11268  AWGAperiodvalue = AWGAperiodvalue + 1
11269  else:
11270  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11271  SamplesPermS = int(BaseSampleRate/1000) # 100
11272  else:
11273  AWGAperiodvalue = 0.0
11274  if AWG_Amp_Mode.get() == 1:
11275  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11276  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11277  else:
11278  if AWGAAmplvalue > AWGAOffsetvalue:
11279  MinV = AWGAOffsetvalue
11280  MaxV = AWGAAmplvalue
11281  else:
11282  MaxV = AWGAOffsetvalue
11283  MinV = AWGAAmplvalue
11284  AWGAwaveform = []
11285  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
11286  Mid = (MaxV+MinV)/2.0
11287  if AWGABurstFlag.get() == 1:
11288  TempOneCycle = AWGAwaveform
11289  for i in range(AWGACycles-1):
11290  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11291  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11292  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11294  BAWGAPhaseDelay()
11295  UpdateAwgCont()
11296 
11298  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
11299  global EnableScopeOnly, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11300 
11301  if AWGAMode.get() == 0: # Source Voltage measure current mode
11302  label_txt = "SVMI"
11303  elif AWGAMode.get() == 1: # Source current measure voltage mode
11304  label_txt = "SIMV"
11305  elif AWGAMode.get() == 2: # High impedance mode
11306  label_txt = "Hi-Z"
11307  if AWGAIOMode.get() > 0: # Split Input / Output mode
11308  if HWRevOne == "D":
11309  if AWGAMode.get() == 0:
11310  AWGAMode.set(1)
11311  CHA.set_mode('i') # channel must be in source current mode for rev D boards
11312  label_txt = "SIMV"
11313  label_txt = label_txt + " Split I/O"
11314  if EnableScopeOnly == 0:
11315  label_txt = label_txt + " Mode"
11316  AWGAModeLabel.config(text = label_txt ) # change displayed value
11317  ReMakeAWGwaves()
11318  #UpdateAwgCont()
11319 
11321  global AWGAAmplvalue, AWGAOffsetvalue, EnableScopeOnly
11322  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
11323  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
11324  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
11325  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11326  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
11327  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11328 
11329  BAWGAAmpl(0)
11330  BAWGAOffset(0)
11331  BAWGAFreq(0)
11332  BAWGAPhase(0)
11333  BAWGADutyCycle(0)
11334  BAWGAShape()
11335 
11336  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
11337  amp1lab.config(text = "Min Ch A" ) # change displayed value
11338  off1lab.config(text = "Max Ch A" ) # change displayed value
11339  else:
11340  amp1lab.config(text = "Amp Ch A" )
11341  off1lab.config(text = "Off Ch A" )
11342 
11343  if AWGAFreqvalue > 0.0:
11344  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11345  else:
11346  AWGAperiodvalue = 0.0
11347 
11348  if AWGAPhaseDelay.get() == 0:
11349  if AWGAWave == 'square':
11350  AWGAPhasevalue = AWGAPhasevalue + 270.0
11351  if AWGAPhasevalue > 359:
11352  AWGAPhasevalue = AWGAPhasevalue - 360
11353  if AWGAPhasevalue > 0:
11354  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11355  else:
11356  AWGAdelayvalue = 0.0
11357  elif AWGAPhaseDelay.get() == 1:
11358  AWGAdelayvalue = AWGAPhasevalue * 100
11359 
11360  if AWGATerm.get() == 0: # Open termination
11361  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11362  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11363  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
11364  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11365  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
11366  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
11367  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
11368  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11369 
11370  if AWGAWave == 'dc':
11371  if AWG_2X.get() == 2:
11372  AWGAWave == 'arbitrary'
11373  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11374  else:
11375  if AWGAMode.get() == 0: # Source Voltage measure current mode
11376  if AWGAIOMode.get() == 0:
11377  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11378  else:
11379  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11380  CHA.constant(AWGAOffsetvalue)
11381  #
11382  if AWGAMode.get() == 1: # Source current measure voltage mode
11383  if AWGAIOMode.get() == 0:
11384  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11385  else:
11386  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11387  CHA.constant(AWGAOffsetvalue/1000)
11388  #
11389  if AWGAMode.get() == 2: # High impedance mode
11390  if AWGAIOMode.get() == 0:
11391  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11392  else:
11393  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11394  #
11395  if AWGAIOMode.get() > 0: # Split Input / Output mode
11396  if HWRevOne == "D":
11397  AWGAMode.set(1)
11398  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11399 #
11400  else:
11401  if AWGAMode.get() == 0: # Source Voltage measure current mode
11402  if AWGAIOMode.get() == 0:
11403  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11404  else:
11405  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11406  if AWGAMode.get() == 1: # Source current measure voltage mode
11407  if AWGAIOMode.get() == 0:
11408  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11409  else:
11410  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11411  AWGAOffsetvalue = AWGAOffsetvalue/1000
11412  AWGAAmplvalue = AWGAAmplvalue/1000
11413  if AWGAMode.get() == 2: # High impedance mode
11414  if AWGAIOMode.get() == 0:
11415  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11416  else:
11417  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11418  else:
11419  if AWG_Amp_Mode.get() == 1:
11420  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11421  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11422  else:
11423  MaxV = AWGAOffsetvalue
11424  MinV = AWGAAmplvalue
11425  try:
11426  if AWGAWave == 'sine':
11427  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11428  elif AWGAWave == 'triangle':
11429  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11430  elif AWGAWave == 'sawtooth':
11431  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11432  elif AWGAWave == 'square':
11433  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
11434  elif AWGAWave == 'stairstep':
11435  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11436  elif AWGAWave == 'arbitrary':
11437  if EnableScopeOnly == 0:
11438  AddAWGANoise()
11439  if AWGSync.get() == 0:
11440  AWGARepeatFlag.set(1)
11441  if AWG_2X.get() == 2:
11442  AWGAWave == 'arbitrary'
11443  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11444  else:
11445  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
11446  except:
11447  donothing()
11448  if AWGAIOMode.get() > 0: # Split Input / Output mode
11449  if HWRevOne == "D":
11450  AWGAMode.set(1)
11451  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11452 #
11454  global AWG_2X, AWGB2X, AWGAwaveform
11455  global AWGANoiseEntry, AWGAsbnoise, AWGANoisevalue
11456 
11457  if AWGAsbnoise.get() == "None":
11458  return
11459  else:
11460  try:
11461  AWGANoisevalue = float(eval(AWGANoiseEntry.get()))
11462  except:
11463  AWGANoiseEntry.delete(0,"end")
11464  AWGANoiseEntry.insert(0, AWGANoisevalue)
11465  if AWGANoisevalue == 0.0:
11466  return
11467  AWGANoiseform = []
11468  if AWGAsbnoise.get() == "Gaussian":
11469  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGAwaveform))
11470  else:
11471  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGAwaveform))
11472  AWGAwaveform = AWGAwaveform + AWGANoiseform
11473  if AWG_2X.get() == 2:
11474  if AWGAsbnoise.get() == "Gaussian":
11475  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGB2X))
11476  else:
11477  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGB2X))
11478  AWGB2X = AWGB2X + AWGANoiseform
11479 
11481  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
11482  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
11483  global BisCompA, AWGAWave
11484 
11485  # if BisCompA.get() == 1:
11486  # sawp Min and Max values
11487  if AWGAWave == 'dc':
11488  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
11489  AWGBOffsetvalue = 2.5 - (float(eval(AWGAOffsetEntry.get()))-2.5)
11490  AWGBAmplEntry.delete(0,"end")
11491  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11492  AWGBOffsetEntry.delete(0,"end")
11493  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11494  else:
11495  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
11496  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
11497  AWGBAmplEntry.delete(0,"end")
11498  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
11499  AWGBOffsetEntry.delete(0,"end")
11500  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
11501  # copy everything else
11502  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
11503  AWGBFreqEntry.delete(0,"end")
11504  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11505  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
11506  AWGBPhaseEntry.delete(0,"end")
11507  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11508  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
11509  AWGBDutyCycleEntry.delete(0,"end")
11510  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11511  AWGBShape.set(AWGAShape.get())
11512  #
11513 # ReMakeAWGwaves()
11514 # UpdateAwgCont()
11515 #
11516 # AWG B functions
11518  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
11519 
11520  if AWGBBurstFlag.get() == 1:
11521  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
11522  if (AWGBCyclesString == None): # If Cancel pressed, then None
11523  return
11524  AWGBCycles = int(AWGBCyclesString)
11525  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
11526  if (AWGBDelayString == None): # If Cancel pressed, then None
11527  return
11528  AWGBBurstDelay = float(AWGBDelayString)
11529  ReMakeAWGwaves()
11530 #
11531 def BAWGBAmpl(temp):
11532  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11533  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11534 
11535  try:
11536  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
11537  except:
11538  AWGBAmplEntry.delete(0,"end")
11539  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11540  #
11541  if AWGBMode.get() == 0: # Source Voltage measure current mode
11542  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
11543  if AWGBAmplvalue > 5.00:
11544  AWGBAmplvalue = 5.00
11545  AWGBAmplEntry.delete(0,"end")
11546  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11547  if AWGBAmplvalue < 0.00:
11548  AWGBAmplvalue = 0.00
11549  AWGBAmplEntry.delete(0,"end")
11550  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11551  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
11552  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
11553  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
11554  AWGBAmplEntry.delete(0,"end")
11555  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11556  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
11557  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
11558  AWGBAmplEntry.delete(0,"end")
11559  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11560  elif AWGBMode.get() == 1: # Source current measure voltage mode
11561  if AWGBAmplvalue > 200.00:
11562  AWGBAmplvalue = 200.00
11563  AWGBAmplEntry.delete(0,"end")
11564  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11565  if AWGBAmplvalue < -200.00:
11566  AWGBAmplvalue = -200.00
11567  AWGBAmplEntry.delete(0,"end")
11568  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11569 #
11570 def BAWGBOffset(temp):
11571  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11572  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11573 
11574  try:
11575  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
11576  except:
11577  AWGBOffsetEntry.delete(0,"end")
11578  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11579  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
11580  if AWGBMode.get() == 0: # Source Voltage measure current mode
11581  if AWGBOffsetvalue > 5.00:
11582  AWGBOffsetvalue = 5.00
11583  AWGBOffsetEntry.delete(0,"end")
11584  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11585  if AWGBOffsetvalue < 0.00:
11586  AWGBOffsetvalue = 0.00
11587  AWGBOffsetEntry.delete(0,"end")
11588  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11589  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
11590  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
11591  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
11592  AWGBOffsetEntry.delete(0,"end")
11593  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11594  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
11595  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
11596  AWGBOffsetEntry.delete(0,"end")
11597  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11598  if AWGBMode.get() == 1: # Source current measure voltage mode
11599  if AWGBOffsetvalue > 200.00:
11600  AWGBOffsetvalue = 200.00
11601  AWGBOffsetEntry.delete(0,"end")
11602  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11603  if AWGBOffsetvalue < -200.00:
11604  AWGBOffsetvalue = -200.00
11605  AWGBOffsetEntry.delete(0,"end")
11606  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11607 #
11608 def BAWGBFreq(temp):
11609  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
11610  global BodeScreenStatus, BodeDisp, AWGRecLength
11611 
11612  try:
11613  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
11614  except:
11615  AWGBFreqEntry.delete(0,"end")
11616  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11617  if AWG_2X.get() == 2:
11618  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
11619  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
11620  AWGBFreqvalue = 90000
11621  AWGBFreqEntry.delete(0,"end")
11622  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11623  else:
11624  if AWGBFreqvalue > 50000: # max freq is 50KHz
11625  AWGBFreqvalue = 50000
11626  AWGBFreqEntry.delete(0,"end")
11627  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11628  else:
11629  if AWGBFreqvalue > 25000: # max freq is 25KHz
11630  AWGBFreqvalue = 25000
11631  AWGBFreqEntry.delete(0,"end")
11632  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11633  if AWGBFreqvalue < 4.0:
11634  AWGRecLength = 32768*2
11635  else:
11636  AWGRecLength = 32768
11637  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
11638  AWGBFreqvalue = 10
11639  AWGBFreqEntry.delete(0,"end")
11640  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11641  # UpdateAWGB()
11642 
11644  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
11645 
11646  if AWGBPhaseDelay.get() == 1:
11647  AWGBPhaseDelay.set(0)
11648  awgbph.configure(text="Phase")
11649  phaseblab.configure(text="Deg")
11650  elif AWGBPhaseDelay.get() == 0:
11651  AWGBPhaseDelay.set(1)
11652  awgbph.configure(text="Delay")
11653  phaseblab.configure(text="mSec")
11654 
11656  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
11657 
11658  if AWGBPhaseDelay.get() == 0:
11659  phaseblab.configure(text="Deg")
11660  awgbph.configure(text="Phase")
11661  elif AWGBPhaseDelay.get() == 1:
11662  phaseblab.configure(text="mSec")
11663  awgbph.configure(text="Delay")
11664 
11665 def BAWGBPhase(temp):
11666  global AWGBPhaseEntry, AWGBPhasevalue
11667 
11668  try:
11669  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
11670  except:
11671  AWGBPhaseEntry.delete(0,"end")
11672  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11673 
11674  if AWGBPhasevalue > 360: # max phase is 360 degrees
11675  AWGBPhasevalue = 360
11676  AWGBPhaseEntry.delete(0,"end")
11677  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11678  if AWGBPhasevalue < 0: # min phase is 0 degrees
11679  AWGBPhasevalue = 0
11680  AWGBPhaseEntry.delete(0,"end")
11681  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11682 
11683 def BAWGBDutyCycle(temp):
11684  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
11685 
11686  try:
11687  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
11688  except:
11689  AWGBDutyCycleEntry.delete(0,"end")
11690  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11691 
11692  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
11693  AWGBDutyCyclevalue = 1
11694  AWGBDutyCycleEntry.delete(0,"end")
11695  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
11696  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
11697  AWGBDutyCyclevalue = 0
11698  AWGBDutyCycleEntry.delete(0,"end")
11699  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11700  # UpdateAWGB()
11701 
11703  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
11704 
11705  if AWGBShape.get() == 0:
11706  AWGBWave = 'dc'
11707  duty2lab.config(text="%")
11708  BAWGBPhaseDelay()
11709  if AWGBShape.get() == 1:
11710  AWGBWave = 'sine'
11711  duty2lab.config(text="%")
11712  BAWGBPhaseDelay()
11713  if AWGBShape.get() == 2:
11714  AWGBWave = 'triangle'
11715  duty2lab.config(text="%")
11716  BAWGBPhaseDelay()
11717  if AWGBShape.get() == 3:
11718  AWGBWave = 'sawtooth'
11719  duty2lab.config(text="%")
11720  BAWGBPhaseDelay()
11721  if AWGBShape.get() == 4:
11722  AWGBWave = 'square'
11723  duty2lab.config(text="%")
11724  BAWGBPhaseDelay()
11725  if AWGBShape.get() == 5:
11726  AWGBWave = 'stairstep'
11727  duty2lab.config(text="%")
11728  BAWGBPhaseDelay()
11729  if AWGBShape.get() > 5:
11730  AWGBWave = 'arbitrary'
11731  if AWG_2X.get() == 1:
11732  CHB.mode = CHA.mode
11733  AWGBWave = 'arbitrary'
11734  # UpdateAWGB()
11735 
11737  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile
11738 
11739  # Read values from CVS file
11740  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11741  AWGBcsvFile = filename
11742  AWGBLoadCSV()
11743 #
11745  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile, AWGBOffsetvalue
11746 
11747  BAWGBOffset(0)
11748  try:
11749  CSVFile = open(AWGBcsvFile)
11750  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
11751  CSVFile.seek(0)
11752  #csv_f = csv.reader(CSVFile, dialect)
11753  csv_f = csv.reader(CSVFile, csv.excel)
11754  except:
11755  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
11756  AWGBwaveform = []
11757  ColumnNum = 0
11758  ColumnSel = 0
11759  RowNum = 0
11760  for row in csv_f:
11761  if len(row) > 1 and ColumnSel == 0:
11762  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
11763  ColumnNum = int(RequestColumn) - 1
11764  ColumnLen = str(len(row))
11765  ColumnSel = 1
11766  try:
11767  colnum = 0
11768  for col in row:
11769  if colnum == ColumnNum:
11770  AWGBwaveform.append(float(col))
11771  colnum += 1
11772  except:
11773  print( 'skipping non-numeric row', RowNum)
11774  RowNum += 1
11775  AWGBwaveform = numpy.array(AWGBwaveform)
11776  AWGBwaveform = AWGBwaveform + AWGBOffsetvalue # add DC offset from Max entry
11778  CSVFile.close()
11779  UpdateAwgCont()
11780 
11781 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
11783  global AWG_2X, AWGB2X, AWGBwaveform
11784  global AWGFiltB, AWGFiltBCoef
11785 
11786  # check if AWG digital filter box checked
11787  if AWGFiltB.get() == 1:
11788  BufLen = len(AWGBwaveform)
11789  CoefLen = len(AWGFiltBCoef)/2
11790  AWGBwaveform = numpy.pad(AWGBwaveform, (CoefLen,CoefLen), 'wrap')
11791  AWGBwaveform = numpy.convolve(AWGBwaveform, AWGFiltBCoef)
11792  AWGBwaveform = numpy.roll(AWGBwaveform, -CoefLen)
11793  AWGBwaveform = AWGBwaveform[CoefLen:BufLen+CoefLen]
11794 
11795  if AWG_2X.get() == 2:
11796  Tempwaveform = []
11797  AWGB2X = []
11798  AWGB2X = AWGBwaveform[::2] # even numbered samples
11799  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
11800  AWGBwaveform = Tempwaveform
11801 #
11803  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
11804  global AWG_2X, AWGA2X
11805 
11806 # Read values from WAV file
11807  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
11808  AWGBwavFile = filename
11809  AWGBLoadWAV()
11810 #
11812  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
11813  global AWG_2X, AWGA2X
11814 
11815  try:
11816  spf = wave.open(AWGBwavFile,'r')
11817  except:
11818  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
11819  AWGBwaveform = []
11820  #If Stereo
11821  if spf.getnchannels() == 2:
11822  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
11823  return()
11824  #Extract Raw Audio from Wav File
11825  Length = spf.getnframes()
11826  if Length > 90000: # limit to first 90K samples
11827  Length = 90000
11828  signal = spf.readframes(Length)
11829  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
11830  # offset and scale for 0 5 V range
11831  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
11832  AWGBwaveform = numpy.array(AWGBwaveform)
11834  spf.close()
11835  UpdateAwgCont()
11836 
11838  global AWGBwaveform, AWGBLength, awgwindow
11839 
11840  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11841  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
11842 
11844  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11845  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
11846  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
11847  global DFiltACoef, DFiltBCoef, AWGBShapeLabel, AWGBLength
11848  global AWG_2X, AWGA2X
11849 
11850  TempString = AWGBMathString
11851  AWGBShapeLabel.config(text = "Math" ) # change displayed value
11852  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
11853  if (AWGBMathString == None): # If Cancel pressed, then None
11854  AWGBMathString = TempString
11855  return
11856  try:
11857  AWGBwaveform = eval(AWGBMathString)
11858  except:
11859  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
11860  AWGBwaveform = numpy.array(AWGBwaveform)
11862  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11863  UpdateAwgCont()
11864 #
11866  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11867  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
11868  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
11869  global DFiltACoef, DFiltBCoef, AWGBShapeLabel
11870  global AWG_2X, AWGA2X
11871 
11872  AWGBwaveform = eval(AWGBMathString)
11873  AWGBwaveform = numpy.array(AWGBwaveform)
11875  UpdateAwgCont()
11876 #
11878  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
11879  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11880  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, duty2lab
11881  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11882 
11883  Max_term = int(AWGBDutyCyclevalue*100)
11884 
11885  BAWGBAmpl(0)
11886  BAWGBOffset(0)
11887  BAWGBFreq(0)
11888  if AWG_2X.get() == 1:
11889  TempRate = (BaseSampleRate*2)
11890  else:
11891  TempRate = BaseSampleRate
11892  AWGBwaveform = []
11893  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGBFreqvalue))) # the fundamental
11894  k = 3
11895  while k <= Max_term:
11896  # Add odd harmonics up to max_term
11897  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGBFreqvalue))))
11898  AWGBwaveform = AWGBwaveform + Harmonic
11899  k = k + 2 # skip even numbers
11900  if AWG_Amp_Mode.get() == 0:
11901  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
11902  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
11903  else:
11904  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
11905  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
11906  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
11908  duty2lab.config(text="Harmonics")
11909  BAWGBPhaseDelay()
11910  UpdateAwgCont()
11911 #
11913  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
11914  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
11915  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
11916  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11917 
11918  BAWGBAmpl(0)
11919  BAWGBOffset(0)
11920  BAWGBFreq(0)
11921  BAWGBPhase(0)
11922  BAWGBDutyCycle(0)
11923 
11924  if AWGBFreqvalue < 1.53 : # if frequency is less than 1.53 Hz use libsmu sine function
11925  AWGBShape.set(1)
11926  BAWGBShape()
11927  UpdateAwgCont()
11928  return
11929 
11930  if AWGBFreqvalue > 0.0:
11931  if AWG_2X.get() == 2:
11932  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11933  else:
11934  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11935  else:
11936  AWGBperiodvalue = 10.0
11937 
11938  if AWGBPhaseDelay.get() == 0:
11939  if AWGBPhasevalue > 0:
11940  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
11941  else:
11942  AWGBdelayvalue = 0.0
11943  elif AWGBPhaseDelay.get() == 1:
11944  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
11945  Cycles = int(AWGRecLength/AWGBperiodvalue)
11946  if Cycles < 1:
11947  Cycles = 1
11948  RecLength = int(Cycles * AWGBperiodvalue)
11949  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11950  RecLength = RecLength + 1
11951  AWGBwaveform = []
11952  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11953 
11954  if AWG_Amp_Mode.get() == 0:
11955  if AWGBMode.get() == 1: # convert to mA
11956  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
11957  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
11958  else:
11959  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
11960  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
11961  else:
11962  if AWGBMode.get() == 1: # convert to mA
11963  amplitude = AWGBAmplvalue/1000.0
11964  offset = AWGBOffsetvalue/1000.0
11965  else:
11966  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
11967  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
11968  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
11969  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
11970  #
11971  if AWG_2X.get() == 2:
11972  Tempwaveform = []
11973  AWGB2X = []
11974  AWGB2X = AWGBwaveform[::2] # even numbered samples
11975  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
11976  AWGBwaveform = Tempwaveform
11977  BAWGBPhaseDelay()
11978  duty2lab.config(text="%")
11979  UpdateAwgCont()
11980 #
11982  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
11983  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11984  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
11985  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11986 
11987  BAWGBAmpl(0)
11988  BAWGBOffset(0)
11989  BAWGBFreq(0)
11990  BAWGBPhase(0)
11991  BAWGBDutyCycle(0)
11992 
11993  if AWGBFreqvalue > 0.0:
11994  if AWG_2X.get() == 2:
11995  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11996  else:
11997  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11998  else:
11999  AWGBperiodvalue = 0.0
12000  if AWG_Amp_Mode.get() == 1:
12001  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12002  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12003  else:
12004  MaxV = AWGBOffsetvalue
12005  MinV = AWGBAmplvalue
12006 
12007  PulseWidth = int(AWGBDutyCyclevalue*100)
12008  PulseSamples = int(AWGBperiodvalue/PulseWidth)
12009  AWGBwaveform = []
12010  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
12011  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
12012  # print(v)
12013  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
12014  if j >= v:
12015  AWGBwaveform.append(MaxV) # j>=v?1:0
12016  else:
12017  AWGBwaveform.append(MinV) # j>=v?1:0
12019  duty2lab.config(text="PWidth")
12020  UpdateAwgCont()
12021 #
12023  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12024  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
12025  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12026  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12027 
12028  BAWGBAmpl(0)
12029  BAWGBOffset(0)
12030  BAWGBFreq(0)
12031  BAWGBPhase(0)
12032  BAWGBDutyCycle(0)
12033 
12034  if AWGBFreqvalue > 0.0:
12035  if AWG_2X.get() == 1:
12036  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
12037  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12038  AWGBperiodvalue = AWGBperiodvalue + 1
12039  else:
12040  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12041  else:
12042  AWGBperiodvalue = 0.0
12043  if AWG_Amp_Mode.get() == 1:
12044  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12045  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12046  else:
12047  MaxV = AWGBOffsetvalue
12048  MinV = AWGBAmplvalue
12049 
12050  if AWGBPhaseDelay.get() == 0:
12051  if AWGBPhasevalue > 0:
12052  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12053  else:
12054  AWGBdelayvalue = 0.0
12055  elif AWGBPhaseDelay.get() == 1:
12056  AWGBdelayvalue = AWGBPhasevalue * SAMPLErate / 1000
12057 
12058  Cycles = int(AWGBDutyCyclevalue*100)
12059  NCycles = -1 * Cycles
12060  AWGBwaveform = []
12061  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGBFreqvalue)))
12062  amplitude = (MaxV-MinV) / 2.0
12063  offset = (MaxV+MinV) / 2.0
12064  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12065  Cycles = int(37500/AWGBperiodvalue)
12066  if Cycles < 1:
12067  Cycles = 1
12068  if Cycles > 1:
12069  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
12070  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
12071  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12073  duty2lab.config(text="Cycles")
12074  BAWGBPhaseDelay()
12075  UpdateAwgCont()
12076 #
12078  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12079  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12080  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12081  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12082  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12083  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12084 
12085  BAWGBAmpl(0)
12086  BAWGBOffset(0)
12087  BAWGBFreq(0)
12088  BAWGBPhase(0)
12089  BAWGBDutyCycle(0)
12090 
12091  if AWGBFreqvalue > 0.0:
12092  if AWG_2X.get() == 2:
12093  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12094  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12095  else:
12096  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12097  SamplesPermS = int(BaseSampleRate/1000) # 100
12098  else:
12099  AWGBperiodvalue = 0.0
12100  if AWG_Amp_Mode.get() == 1:
12101  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12102  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12103  else:
12104  MaxV = AWGBOffsetvalue
12105  MinV = AWGBAmplvalue
12106  AWGBwaveform = []
12107  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12108  if SlopeValue <= 0:
12109  SlopeValue = 1
12110  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12111  if PulseWidth <=0:
12112  PulseWidth = 1
12113  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
12114  if Remainder <= 0:
12115  Remainder = 1
12116  PulseWidth = PulseWidth - SlopeValue
12117  if PulseWidth <=0:
12118  PulseWidth = 1
12119  StepAmp = (MaxV - MinV)/2
12120  StepOff = (MaxV + MinV)/2
12121  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
12122  MidArray = numpy.ones(PulseWidth) * MinV
12123  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
12124  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
12125  if AWGBBurstFlag.get() == 1:
12126  TempOneCycle = AWGBwaveform
12127  for i in range(AWGBCycles-1):
12128  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12129  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12130  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12132  duty2lab.config(text="%")
12133  phaseblab.config(text = "Rise Time")
12134  UpdateAwgCont()
12135 #
12137  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12138  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12139  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12140  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12141  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12142  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12143 
12144  BAWGBAmpl(0)
12145  BAWGBOffset(0)
12146  BAWGBFreq(0)
12147  BAWGBPhase(0)
12148  BAWGBDutyCycle(0)
12149 
12150  if AWGBFreqvalue > 0.0:
12151  if AWG_2X.get() == 2:
12152  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12153  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12154  else:
12155  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12156  SamplesPermS = int(BaseSampleRate/1000) # 100
12157  else:
12158  AWGBperiodvalue = 0.0
12159  if AWG_Amp_Mode.get() == 1:
12160  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12161  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12162  else:
12163  MaxV = AWGBOffsetvalue
12164  MinV = AWGBAmplvalue
12165  AWGBwaveform = []
12166  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12167  if SlopeValue <= 0:
12168  SlopeValue = 1
12169  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12170  if PulseWidth <=0:
12171  PulseWidth = 1
12172  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12173  if Remainder <= 0:
12174  Remainder = 1
12175  PulseWidth = PulseWidth - SlopeValue
12176  if PulseWidth <=0:
12177  PulseWidth = 1
12178  StepValue = (MaxV - MinV) / SlopeValue
12179  SampleValue = MinV
12180  for i in range(SlopeValue):
12181  AWGBwaveform.append(SampleValue)
12182  SampleValue = SampleValue + StepValue
12183  for i in range(PulseWidth):
12184  AWGBwaveform.append(MaxV)
12185  for i in range(SlopeValue):
12186  AWGBwaveform.append(SampleValue)
12187  SampleValue = SampleValue - StepValue
12188  for i in range(Remainder):
12189  AWGBwaveform.append(MinV)
12190  if AWGBBurstFlag.get() == 1:
12191  TempOneCycle = AWGBwaveform
12192  for i in range(AWGBCycles-1):
12193  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12194  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12195  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12197  duty2lab.config(text="%")
12198  phaseblab.config(text = "Rise Time")
12199  UpdateAwgCont()
12200 #
12202  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12203  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12204  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12205  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12206  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12207  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12208 
12209  BAWGBAmpl(0)
12210  BAWGBOffset(0)
12211  BAWGBFreq(0)
12212  BAWGBPhase(0)
12213 
12214  try:
12215  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
12216  except:
12217  AWGBDutyCycleEntry.delete(0,"end")
12218  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12219 
12220  if AWGBFreqvalue > 0.0:
12221  if AWG_2X.get() == 2:
12222  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12223  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12224  else:
12225  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12226  SamplesPermS = int(BaseSampleRate/1000) # 100
12227  else:
12228  AWGBperiodvalue = 0.0
12229  if AWG_Amp_Mode.get() == 1:
12230  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12231  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12232  else:
12233  MaxV = AWGBOffsetvalue
12234  MinV = AWGBAmplvalue
12235  AWGBwaveform = []
12236  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12237  if SlopeValue <= 0:
12238  SlopeValue = 1
12239  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
12240  if PulseWidth <=0:
12241  PulseWidth = 1
12242  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12243  if Remainder <= 0:
12244  Remainder = 1
12245  PulseWidth = PulseWidth - SlopeValue
12246  if PulseWidth <=0:
12247  PulseWidth = 1
12248  StepValue = (MaxV - MinV) / SlopeValue
12249  SampleValue = MinV
12250  for i in range(SlopeValue):
12251  AWGBwaveform.append(SampleValue)
12252  SampleValue = SampleValue + StepValue
12253  for i in range(PulseWidth):
12254  AWGBwaveform.append(MaxV)
12255  for i in range(SlopeValue):
12256  AWGBwaveform.append(SampleValue)
12257  SampleValue = SampleValue - StepValue
12258  for i in range(Remainder):
12259  AWGBwaveform.append(MinV)
12260  if AWGBBurstFlag.get() == 1:
12261  TempOneCycle = AWGBwaveform
12262  for i in range(AWGBCycles-1):
12263  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12264  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12265  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12267  duty2lab.config(text="Width mS")
12268  phaseblab.config(text = "Rise Time")
12269  UpdateAwgCont()
12270 #
12272  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12273  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12274  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12275  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12276  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12277  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12278 
12279  BAWGBAmpl(0)
12280  BAWGBOffset(0)
12281  BAWGBFreq(0)
12282  BAWGBPhase(0)
12283  BAWGBDutyCycle(0)
12284 
12285  if AWGBFreqvalue > 0.0:
12286  if AWG_2X.get() == 2:
12287  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12288  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12289  else:
12290  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12291  SamplesPermS = int(BaseSampleRate/1000) # 100
12292  else:
12293  AWGBperiodvalue = 0.0
12294  if AWG_Amp_Mode.get() == 1:
12295  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12296  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12297  else:
12298  MaxV = AWGBOffsetvalue
12299  MinV = AWGBAmplvalue
12300  AWGBwaveform = []
12301  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12302  if SlopeValue <= 0:
12303  SlopeValue = 1
12304  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12305  if PulseWidth <=0:
12306  PulseWidth = 1
12307  Remainder = int(AWGBperiodvalue - PulseWidth)
12308  if Remainder <= 0:
12309  Remainder = 1
12310  PulseWidth = PulseWidth - SlopeValue
12311  if PulseWidth <=0:
12312  PulseWidth = 1
12313  StepValue = (MaxV - MinV) / SlopeValue
12314  SampleValue = MinV
12315  for i in range(SlopeValue):
12316  AWGBwaveform.append(SampleValue)
12317  SampleValue = SampleValue + StepValue
12318  for i in range(PulseWidth):
12319  AWGBwaveform.append(MaxV)
12320  for i in range(Remainder):
12321  AWGBwaveform.append(MinV)
12322  if AWGBBurstFlag.get() == 1:
12323  TempOneCycle = AWGBwaveform
12324  for i in range(AWGBCycles-1):
12325  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12326  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12327  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12329  duty2lab.config(text="%")
12330  phaseblab.config(text = "Slope Time")
12331  UpdateAwgCont()
12332 #
12334  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12335  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12336  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12337  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12338  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12339  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12340 
12341  BAWGBAmpl(0)
12342  BAWGBOffset(0)
12343  BAWGBFreq(0)
12344  BAWGBPhase(0)
12345  BAWGBDutyCycle(0)
12346 
12347  if AWGBFreqvalue > 0.0:
12348  if AWG_2X.get() == 2:
12349  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12350  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12351  else:
12352  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12353  SamplesPermS = int(BaseSampleRate/1000) # 100
12354  else:
12355  AWGBperiodvalue = 0.0
12356  if AWG_Amp_Mode.get() == 1:
12357  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12358  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12359  else:
12360  MaxV = AWGBOffsetvalue
12361  MinV = AWGBAmplvalue
12362  #
12363  if AWGBPhaseDelay.get() == 0:
12364  if AWGBPhasevalue > 0:
12365  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12366  else:
12367  AWGBdelayvalue = 0.0
12368  elif AWGBPhaseDelay.get() == 1:
12369  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12370  #
12371  AWGBwaveform = []
12372  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12373  if PulseWidth <=0:
12374  PulseWidth = 1
12375  Remainder = int(AWGBperiodvalue - PulseWidth)
12376  if Remainder <= 0:
12377  Remainder = 1
12378  UpStepValue = (MaxV - MinV) / PulseWidth
12379  DownStepValue = (MaxV - MinV) / Remainder
12380  SampleValue = MinV
12381  for i in range(PulseWidth):
12382  AWGBwaveform.append(SampleValue)
12383  SampleValue = SampleValue + UpStepValue
12384  for i in range(Remainder):
12385  AWGBwaveform.append(SampleValue)
12386  SampleValue = SampleValue - DownStepValue
12387  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12388  if AWGBBurstFlag.get() == 1:
12389  TempOneCycle = AWGBwaveform
12390  for i in range(AWGBCycles-1):
12391  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12392  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12393  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12395  BAWGBPhaseDelay()
12396  duty2lab.config(text = "Symmetry")
12397  BAWGBPhaseDelay()
12398  UpdateAwgCont()
12399 #
12401  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12402  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12403  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12404  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12405  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12406  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12407 
12408  BAWGBAmpl(0)
12409  BAWGBOffset(0)
12410  BAWGBFreq(0)
12411  BAWGBPhase(0)
12412  BAWGBDutyCycle(0)
12413 
12414  if AWGBFreqvalue > 0.0:
12415  if AWG_2X.get() == 2:
12416  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12417  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12418  else:
12419  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12420  SamplesPermS = int(BaseSampleRate/1000) # 100
12421  else:
12422  AWGBperiodvalue = 0.0
12423  if AWG_Amp_Mode.get() == 1:
12424  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12425  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12426  else:
12427  MaxV = AWGBOffsetvalue
12428  MinV = AWGBAmplvalue
12429  AWGBwaveform = []
12430  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
12431  if AWGBPhaseDelay.get() == 0:
12432  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
12433  elif AWGBPhaseDelay.get() == 1:
12434  DelayValue = int(AWGBPhasevalue*SamplesPermS)
12435  for i in range(DelayValue-PulseWidth):
12436  AWGBwaveform.append((MinV+MaxV)/2)
12437  for i in range(PulseWidth):
12438  AWGBwaveform.append(MaxV)
12439  for i in range(PulseWidth):
12440  AWGBwaveform.append(MinV)
12441  DelayValue = int(AWGBperiodvalue-DelayValue)
12442  for i in range(DelayValue-PulseWidth):
12443  AWGBwaveform.append((MinV+MaxV)/2)
12444  if AWGBBurstFlag.get() == 1:
12445  TempOneCycle = AWGBwaveform
12446  for i in range(AWGBCycles-1):
12447  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12448  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12449  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12451  duty2lab.config(text = "Duty Cycle")
12452  BAWGBPhaseDelay()
12453  UpdateAwgCont()
12454 
12456  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
12457  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12458  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12459  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12460  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12461 
12462  BAWGBAmpl(0)
12463  BAWGBOffset(0)
12464  BAWGBFreq(0)
12465 
12466  if AWGBFreqvalue > 0.0:
12467  if AWG_2X.get() == 2:
12468  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12469  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12470  else:
12471  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12472  SamplesPermS = int(BaseSampleRate/1000) # 100
12473  else:
12474  AWGBperiodvalue = 0.0
12475 
12476  if AWGBAmplvalue > AWGBOffsetvalue:
12477  MinV = AWGBOffsetvalue
12478  MaxV = AWGBAmplvalue
12479  else:
12480  MaxV = AWGBOffsetvalue
12481  MinV = AWGBAmplvalue
12482  if AWG_Amp_Mode.get() == 1:
12483  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12484  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12485  AWGBwaveform = []
12486  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
12487  Mid = (MaxV+MinV)/2
12488  if AWGBBurstFlag.get() == 1:
12489  TempOneCycle = AWGBwaveform
12490  for i in range(AWGBCycles-1):
12491  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12492  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12493  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12495  BAWGBPhaseDelay()
12496  UpdateAwgCont()
12497 
12499  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
12500  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12501  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12502  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12503  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12504 
12505  BAWGBAmpl(0)
12506  BAWGBOffset(0)
12507  BAWGBFreq(0)
12508 
12509  if AWGBFreqvalue > 0.0:
12510  if AWG_2X.get() == 2:
12511  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12512  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12513  else:
12514  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12515  SamplesPermS = int(BaseSampleRate/1000) # 100
12516  else:
12517  AWGBperiodvalue = 0.0
12518  if AWGBAmplvalue > AWGBOffsetvalue:
12519  MinV = AWGBOffsetvalue
12520  MaxV = AWGBAmplvalue
12521  else:
12522  MaxV = AWGBOffsetvalue
12523  MinV = AWGBAmplvalue
12524  if AWG_Amp_Mode.get() == 1:
12525  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12526  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12527  AWGBwaveform = []
12528  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
12529  Mid = (MaxV+MinV)/2
12530  if AWGBBurstFlag.get() == 1:
12531  TempOneCycle = AWGBwaveform
12532  for i in range(AWGBCycles-1):
12533  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12534  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12535  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12537  BAWGBPhaseDelay()
12538  UpdateAwgCont()
12539 
12541  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
12542  global EnableScopeOnly
12543 
12544  if AWGBMode.get() == 0: # Source Voltage measure current mode
12545  label_txt = "SVMI"
12546  elif AWGBMode.get() == 1: # Source current measure voltage mode
12547  label_txt = "SIMV"
12548  elif AWGBMode.get() == 2: # High impedance mode
12549  label_txt = "Hi-Z"
12550  if AWGBIOMode.get() > 0: # Split Input / Output mode
12551  if HWRevOne == "D":
12552  if AWGBMode.get() == 0:
12553  AWGBMode.set(1)
12554  CHB.set_mode('i') # channel must be in source current mode for rev D boards
12555  label_txt = "SIMV"
12556  label_txt = label_txt + " Split I/O"
12557  if EnableScopeOnly == 0:
12558  label_txt = label_txt + " Mode"
12559  AWGBModeLabel.config(text = label_txt ) # change displayed value
12560  ReMakeAWGwaves()
12561  #UpdateAwgCont()
12562 
12564  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
12565  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
12566  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
12567  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
12568  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
12569  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12570  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag, EnableScopeOnly
12571  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12572 
12573  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
12574  amp2lab.config(text = "Min Ch B" ) # change displayed value
12575  off2lab.config(text = "Max Ch B" ) # change displayed value
12576  else:
12577  amp2lab.config(text = "Amp Ch B" )
12578  off2lab.config(text = "Off Ch B" )
12579 #
12580  if AWG_2X.get() == 1:
12581  AWGBWave = 'arbitrary'
12582  if AWGBFreqvalue > 0.0:
12583  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
12584  else:
12585  AWGBperiodvalue = 0.0
12586 #
12587  if AWGBPhaseDelay.get() == 0:
12588  if AWGBWave == 'square':
12589  AWGBPhasevalue = AWGBPhasevalue + 270.0
12590  if AWGBPhasevalue > 359:
12591  AWGBPhasevalue = AWGBPhasevalue - 360
12592  if AWGBPhasevalue > 0:
12593  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12594  else:
12595  AWGBdelayvalue = 0.0
12596  elif AWGBPhaseDelay.get() == 1:
12597  AWGBdelayvalue = AWGBPhasevalue * 100
12598 #
12599  if AWGBTerm.get() == 0: # Open termination
12600  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
12601  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
12602  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
12603  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
12604  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
12605  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
12606  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
12607  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
12608 
12609  if AWGBWave == 'dc':
12610  if AWG_2X.get() == 1:
12611  AWGBWave == 'arbitrary'
12612  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
12613  else:
12614  if AWGBMode.get() == 0: # Source Voltage measure current mode
12615  if AWGBIOMode.get() == 0:
12616  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
12617  else:
12618  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
12619  CHB.constant(AWGBOffsetvalue)
12620  if AWGBMode.get() == 1: # Source current measure Voltage mode
12621  if AWGBIOMode.get() == 0:
12622  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
12623  else:
12624  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
12625  CHB.constant(AWGBOffsetvalue/1000)
12626  if AWGBMode.get() == 2: # Hi impedance mode
12627  if AWGBIOMode.get() == 0:
12628  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
12629  else:
12630  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
12631 #
12632  if AWGBIOMode.get() > 0: # Split Input / Output mode
12633  if HWRevOne == "D":
12634  AWGBMode.set(1)
12635  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12636 #
12637  else:
12638  if AWGBMode.get() == 0: # Source Voltage measure current mode
12639  if AWGBIOMode.get() == 0:
12640  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
12641  else:
12642  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
12643  if AWGBMode.get() == 1: # Source current measure Voltage mode
12644  if AWGBIOMode.get() == 0:
12645  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
12646  else:
12647  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
12648  AWGBOffsetvalue = AWGBOffsetvalue/1000
12649  AWGBAmplvalue = AWGBAmplvalue/1000
12650  if AWGBMode.get() == 2: # Hi impedance mode
12651  if AWGBIOMode.get() == 0:
12652  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
12653  else:
12654  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
12655  else:
12656  if AWG_Amp_Mode.get() == 1:
12657  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12658  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12659  else:
12660  MaxV = AWGBOffsetvalue
12661  MinV = AWGBAmplvalue
12662  try: # keep going even if low level library returns an error
12663  if AWGBWave == 'sine':
12664  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12665  elif AWGBWave == 'triangle':
12666  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12667  elif AWGBWave == 'sawtooth':
12668  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12669  elif AWGBWave == 'square':
12670  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
12671  elif AWGBWave == 'stairstep':
12672  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12673  elif AWGBWave == 'arbitrary':
12674  if EnableScopeOnly == 0:
12675  AddAWGBNoise()
12676  if AWGSync.get() == 0:
12677  AWGBRepeatFlag.set(1)
12678  if AWG_2X.get() == 1:
12679  AWGBWave == 'arbitrary'
12680  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
12681  else:
12682  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
12683  except:
12684  donothing()
12685  if AWGBIOMode.get() > 0: # Split Input / Output mode
12686  if HWRevOne == "D":
12687  AWGBMode.set(1)
12688  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12689 #
12691  global AWG_2X, AWGA2X, AWGBwaveform
12692  global AWGBNoiseEntry, AWGBsbnoise, AWGBNoisevalue
12693 
12694  if AWGBsbnoise.get() == "None":
12695  return
12696  else:
12697  try:
12698  AWGBNoisevalue = float(eval(AWGBNoiseEntry.get()))
12699  except:
12700  AWGBNoiseEntry.delete(0,"end")
12701  AWGBNoiseEntry.insert(0, AWGBNoisevalue)
12702  if AWGBNoisevalue == 0.0:
12703  return
12704  AWGBNoiseform = []
12705  if AWGBsbnoise.get() == "Gaussian":
12706  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGBwaveform))
12707  else:
12708  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGBwaveform))
12709  AWGBwaveform = AWGBwaveform + AWGBNoiseform
12710  if AWG_2X.get() == 2:
12711  if AWGBsbnoise.get() == "Gaussian":
12712  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGA2X))
12713  else:
12714  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGA2X))
12715  AWGA2X = AWGA2X + AWGBNoiseform
12716 #
12718  global session, CHA, CHB, AWGSync
12719  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
12720  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
12721  if session.continuous:
12722  session.end()
12723  BAWGEnab() # set-up new AWG settings
12724  time.sleep(0.01) # wait awhile here for some reason
12725  session.start(0)
12726 #
12728  ReMakeAWGwaves()
12729 
12730 def BAWGEnab():
12731  global AWGAMode, AWGBMode, AWGSync
12732  global CHA, CHB, discontloop, contloop, session
12733 
12734  # Stream = False
12735  # print "Updateing AWGs"
12736  BAWGAAmpl(0)
12737  BAWGAOffset(0)
12738  BAWGAFreq(0)
12739  BAWGAPhase(0)
12740  BAWGADutyCycle(0)
12741  BAWGAShape()
12742  BAWGBAmpl(0)
12743  BAWGBOffset(0)
12744  BAWGBFreq(0)
12745  BAWGBPhase(0)
12746  BAWGBDutyCycle(0)
12747  BAWGBShape()
12748  UpdateAWGA()
12749  UpdateAWGB()
12750 
12751 def BAWGSync():
12752  global RUNstatus, AWGSync, session, CHA, CHB, IAScreenStatus, IADisp
12753 
12754  if (RUNstatus.get() == 1): # do this only if running
12755  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
12756  AWGSync.set(1)
12757  return
12758  if AWGSync.get() == 0:
12759  #UpdateAwgCont()
12760  session.flush()
12761  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
12762  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
12763  BAWGEnab()
12764  session.start(0)
12765  time.sleep(0.02) # wait awhile here for some reason
12766  elif session.continuous:
12767  session.end()
12768  session.flush()
12769  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
12770  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
12771 
12772 # ======= Spectrum Analyzer functions ===========
12773 #
12775  global CANVASwidthF, CANVASheightF, freqwindow
12776  global COLORtext
12777  # ask for file name
12778  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
12779  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
12780  if MarkerNum > 0 or ColorMode.get() > 0:
12781  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
12782  else: # temp change text color to black
12783  COLORtext = "#000000"
12785  # save postscript file
12786  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
12787  #
12788  COLORtext = "#ffffff"
12790 #
12791 def Bnot():
12792  print( "Routine not made yet")
12793 
12795  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12796  ShowC1_VdB.set(1)
12797  ShowC1_P.set(1)
12798  ShowC2_VdB.set(1)
12799  ShowC2_P.set(1)
12800 
12802  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12803  ShowC1_VdB.set(0)
12804  ShowC1_P.set(0)
12805  ShowC2_VdB.set(0)
12806  ShowC2_P.set(0)
12807 
12809  global RUNstatus
12810  global FreqTraceMode
12811 
12812  FreqTraceMode.set(1)
12813  if RUNstatus.get() == 0: # Update if stopped
12815  if RUNstatus.get() == 2: # Restart if running
12816  RUNstatus.set(4)
12817 
12819  global RUNstatus
12820  global FreqTraceMode
12821 
12822  FreqTraceMode.set(2)
12823  if RUNstatus.get() == 0: # Update if stopped
12825  if RUNstatus.get() == 2: # Restart if running
12826  RUNstatus.set(4)
12827 
12829  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
12830 
12831  FreqTraceMode.set(3)
12832 
12833  if RUNstatus.get() == 0: # Update if stopped
12835  if RUNstatus.get() == 2: # Restart if running
12836  RUNstatus.set(4)
12837 
12839  global FreqTraceMode, TRACEresetFreq
12840 
12841  if FreqTraceMode.get()==3:
12842  TRACEresetFreq = True
12843 
12845  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
12846  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
12847  global T1Pline, T2Pline, T1PRline, T2PRline
12848  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12849  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12850  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12851  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12852  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12853 
12854  if ShowC1_VdB.get() == 1:
12855  T1FRline = T1Fline
12856  PeakxRA = PeakxA
12857  PeakyRA = PeakyA
12858  PeakdbRA = PeakdbA
12859  PeakfreqRA = PeakfreqA
12860  if ShowC2_VdB.get() == 1:
12861  T2FRline = T2Fline
12862  PeakxRB = PeakxB
12863  PeakyRB = PeakyB
12864  PeakdbRB = PeakdbB
12865  PeakfreqRB = PeakfreqB
12866  if ShowC1_P.get() == 1:
12867  T1PRline = T1Pline
12868  if ShowC2_P.get() == 1:
12869  T2PRline = T2Pline
12870  if ShowMathSA.get() > 0:
12871  TFRMline = TFMline
12872  PeakxRM = PeakxM
12873  PeakyRM = PeakyM
12874  PeakRMdb = PeakMdb
12875  PeakfreqRM = PeakfreqM
12876 
12877  UpdateFreqTrace() # Always Update
12878 #
12880  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
12881  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
12882  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
12883  global TAPline, TBPline, TAPRline, TBPRline
12884  global TIARline, TIAXline, TIAMagline, TIAAngline
12885  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12886  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12887  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12888  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12889  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12890  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12891 
12892  if ShowCA_VdB.get() == 1:
12893  TAFRline = TAFline
12894  PeakxRA = PeakxA
12895  PeakyRA = PeakyA
12896  PeakdbRA = PeakdbA
12897  PeakfreqRA = PeakfreqA
12898  if ShowCB_VdB.get() == 1:
12899  TBFRline = TBFline
12900  PeakxRB = PeakxB
12901  PeakyRB = PeakyB
12902  PeakdbRB = PeakdbB
12903  PeakfreqRB = PeakfreqB
12904  if ShowCA_P.get() == 1:
12905  TAPRline = TAPline
12906  if ShowCB_P.get() == 1:
12907  TBPRline = TBPline
12908  if ShowMathBP.get() > 0:
12909  TBPRMline = TBPMline
12910  PeakxRM = PeakxM
12911  PeakyRM = PeakyM
12912  PeakRMdb = PeakMdb
12913  PeakfreqRM = PeakfreqM
12914  if Show_Rseries.get() > 0:
12915  RefIARline = TIARline
12916  if Show_Xseries.get() > 0:
12917  RefIAXline = TIAXline
12918  if Show_Magnitude.get() > 0:
12919  RefIAMagline = TIAMagline
12920  if Show_Angle.get() > 0:
12921  RefIAAngline = TIAAngline
12922  UpdateBodeTrace() # Always Update
12923 #
12924 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
12925  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
12926  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, TRACEsize
12927 
12928  # Set the TRACEsize variable
12929  if ShowCA_VdB.get() == 1:
12930  TRACEsize = len(FSweepAdB) # Set the trace length
12931  elif ShowCA_VdB.get() == 1:
12932  TRACEsize = len(FSweepBdB)
12933  if TRACEsize == 0: # If no trace, skip rest of this routine
12934  return()
12935 # ask if save as magnitude or dB
12936  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
12937 # Yes 1 = dB, No 0 = Mag
12938  # Make the file name and open it
12939  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
12940  filename = "Bode-" + tme
12941  filename = filename + ".csv"
12942  # open file to save data
12943  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
12944  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
12945  DataFile = open(filename,'a') # Open output file
12946  HeaderString = 'Frequency-#, '
12947  if ShowCA_VdB.get() == 1:
12948  if dB == 1:
12949  HeaderString = HeaderString + 'CA-dB, '
12950  if dB == 0:
12951  HeaderString = HeaderString + 'CA-Mag, '
12952  if ShowCB_VdB.get() == 1:
12953  if dB == 1:
12954  HeaderString = HeaderString + 'CB-dB, '
12955  if dB == 0:
12956  HeaderString = HeaderString + 'CB-Mag, '
12957  if ShowCA_P.get() == 1:
12958  HeaderString = HeaderString + 'Phase A-B, '
12959  if ShowCB_P.get() == 1:
12960  HeaderString = HeaderString + 'Phase B-A, '
12961  HeaderString = HeaderString + '\n'
12962  DataFile.write( HeaderString )
12963 
12964  n = 0
12965  while n < len(FSweepAdB):
12966  F = FBins[FStep[n]] # look up frequency bin in list of bins
12967  txt = str(F)
12968  if ShowCA_VdB.get() == 1:
12969  V = 10 * math.log10(float(FSweepAdB[n]))
12970  if dB == 0:
12971  V = 10.0**(V/20.0)
12972  txt = txt + "," + str(V)
12973  if ShowCB_VdB.get() == 1:
12974  V = 10 * math.log10(float(FSweepBdB[n]))
12975  if dB == 0:
12976  V = 10.0**(V/20.0)
12977  txt = txt + "," + str(V)
12978  if ShowCA_P.get() == 1:
12979  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
12980  if RelPhase > 180:
12981  RelPhase = RelPhase - 360
12982  elif RelPhase < -180:
12983  RelPhase = RelPhase + 360
12984  txt = txt + "," + str(RelPhase)
12985  if ShowCB_P.get() == 1:
12986  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
12987  if RelPhase > 180:
12988  RelPhase = RelPhase - 360
12989  elif RelPhase < -180:
12990  RelPhase = RelPhase + 360
12991  txt = txt + "," + str(RelPhase)
12992  txt = txt + "\n"
12993  DataFile.write(txt)
12994  n = n + 1
12995 
12996  DataFile.close() # Close the file
12997 
12999  global iawindow, FStep, FBins
13000  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13001 
13002  if NetworkScreenStatus.get() > 0:
13003  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13004  filename = "Impedance-" + tme
13005  filename = filename + ".csv"
13006  # open file to save data
13007  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13008  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
13009  DataFile = open(filename,'a') # Open output file
13010  HeaderString = 'Frequency, Series R, Series X, Series Z, Series Angle'
13011  HeaderString = HeaderString + '\n'
13012  DataFile.write( HeaderString )
13013 
13014  n = 0
13015  while n < len(NSweepSeriesR):
13016  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
13017  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
13018  txt = txt + "\n"
13019  DataFile.write(txt)
13020  n = n + 1
13021  DataFile.close() # Close the file
13022  else:
13023  return
13024 #
13025 def BStartSA():
13026  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
13027  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
13028  global Two_X_Sample, ADC_Mux_Mode, ShowAWGASA, ShowAWGBSA
13029 
13030  #AWGSync.set(0) # always run in continuous mode
13031  if DevID == "No Device":
13032  showwarning("WARNING","No Device Plugged In!")
13033  elif FWRevOne == 0.0:
13034  showwarning("WARNING","Out of data Firmware!")
13035  else:
13036  if PowerStatus == 0:
13037  PowerStatus = 1
13038  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13039  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13040 
13041  if (ShowC1_VdB.get() == 0 and
13042  ShowC2_VdB.get() == 0 and
13043  ShowMathSA.get() == 0 and
13044  ShowAWGASA.get() == 0 and
13045  ShowAWGBSA.get() == 0 and
13046  ShowC1_P.get() == 0 and
13047  ShowC2_P.get() == 0):
13048  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
13049  return()
13050  try:
13051  StopFrequency = float(StopFreqEntry.get())
13052  except:
13053  StopFreqEntry.delete(0,"end")
13054  StopFreqEntry.insert(0,50000)
13055  StopFrequency = 50000
13056  if FWRevOne > 2.16:
13057  if StopFrequency >= 50000:
13058  Two_X_Sample.set(1)
13059  else:
13060  Two_X_Sample.set(0)
13061  ADC_Mux_Mode.set(0)
13062  SetADC_Mux()
13063  #
13064  BStart()
13065 #
13066  UpdateFreqAll() # Always Update
13067 
13068 def BStopSA():
13069  global RUNstatus, session, AWGSync
13070 
13071  if (RUNstatus.get() == 1):
13072  RUNstatus.set(0)
13073  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
13074  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13075  if AWGSync.get() == 0: # running in continuous mode
13076  CHA.constant(0.0)
13077  CHB.constant(0.0)
13078  # print "Stoping continuous mode"
13079  if session.continuous:
13080  # print "Stoping Is Continuous? ", session.continuous
13081  time.sleep(0.02)
13082  #print "Is Continuous? ", session.continuous
13083  else:
13084  contloop = 0
13085  discontloop = 1
13086  session.cancel()
13087  elif (RUNstatus.get() == 2):
13088  RUNstatus.set(3)
13089  elif (RUNstatus.get() == 3):
13090  RUNstatus.set(3)
13091  elif (RUNstatus.get() == 4):
13092  RUNstatus.set(3)
13093  UpdateFreqAll() # Always Update
13094 
13095 def Blevel1():
13096  global DBlevel
13097  global RUNstatus
13098 
13099  DBlevel.set(DBlevel.get() - 1)
13100 
13101  if RUNstatus.get() == 0: # Update if stopped
13102  UpdateFreqTrace()
13103 
13104 def Blevel2():
13105  global DBlevel
13106  global RUNstatus
13107 
13108  DBlevel.set(DBlevel.get() + 1)
13109 
13110  if RUNstatus.get() == 0: # Update if stopped
13111  UpdateFreqTrace()
13112 
13113 def Blevel3():
13114  global DBlevel
13115  global RUNstatus
13116 
13117  DBlevel.set(DBlevel.get() - 10)
13118 
13119  if RUNstatus.get() == 0: # Update if stopped
13120  UpdateFreqTrace()
13121 
13122 def Blevel4():
13123  global DBlevel
13124  global RUNstatus
13125 
13126  DBlevel.set(DBlevel.get() + 10)
13127 
13128  if RUNstatus.get() == 0: # Update if stopped
13129  UpdateFreqTrace()
13130 #
13132  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
13133  global SMPfftpwrTwo, SMPfft, FFTwindow
13134  global TRACEresetFreq, PhAScreenStatus
13135 
13136  if FFTwindow.get() != 8:
13137  if (SMPfftpwrTwo.get() > 6): # Min 64
13138  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
13139  TRACEresetFreq = True # Reset trace peak and trace average
13140  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13141 
13142  if RUNstatus.get() == 0: # Update if stopped
13143  if SpectrumScreenStatus.get() > 0:
13145  if IAScreenStatus.get() > 0:
13146  UpdateIAScreen()
13147  if PhAScreenStatus.get() > 0:
13148  UpdatePhAScreen()
13149  if RUNstatus.get() == 2: # Restart if running
13150  RUNstatus.set(4)
13151 
13153  global RUNstatus, PhAScreenStatus
13154  global SMPfftpwrTwo, SMPfft, FFTwindow
13155  global TRACEresetFreq, SpectrumScreenStatus, IAScreenStatus
13156 
13157  if FFTwindow.get() != 8:
13158  if (SMPfftpwrTwo.get() < 16): # Max 65536
13159  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
13160  TRACEresetFREQ = True # Reset trace peak and trace average
13161  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13162 
13163  if RUNstatus.get() == 0: # Update if stopped
13164  if SpectrumScreenStatus.get() > 0:
13166  if IAScreenStatus.get() > 0:
13167  UpdateIAScreen()
13168  if PhAScreenStatus.get() > 0:
13169  UpdatePhAScreen()
13170  if RUNstatus.get() == 2: # Restart if running
13171  RUNstatus.set(4)
13172 
13173 def BDBdiv1():
13174  global DBdivindex
13175  global RUNstatus
13176 
13177  if (DBdivindex.get() >= 1):
13178  DBdivindex.set(DBdivindex.get() - 1)
13179 
13180  if RUNstatus.get() == 0: # Update if stopped
13181  UpdateFreqTrace()
13182 
13183 def BDBdiv2():
13184  global DBdivindex
13185  global DBdivlist
13186  global RUNstatus
13187 
13188  if (DBdivindex.get() < len(DBdivlist) - 1):
13189  DBdivindex.set(DBdivindex.get() + 1)
13190 
13191  if RUNstatus.get() == 0: # Update if stopped
13192  UpdateFreqTrace()
13193 #----- Bode Plot controls
13194 def BStartBP():
13195  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
13196  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
13197  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
13198  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
13199  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
13200  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
13201  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
13202  global BeginIndex, EndIndex
13203 
13204  if DevID == "No Device":
13205  showwarning("WARNING","No Device Plugged In!")
13206  elif FWRevOne == 0.0:
13207  showwarning("WARNING","Out of data Firmware!")
13208  else:
13209  if PowerStatus == 0:
13210  PowerStatus = 1
13211  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13212  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13213 
13214  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
13215  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
13216  return()
13217  #
13218  if ZEROstuffing.get() < 3:
13219  ZEROstuffing.set(3)
13220  CutDC.set(1) # set to remove DC
13221  try:
13222  EndFreq = float(StopBodeEntry.get())
13223  except:
13224  StopBodeEntry.delete(0,"end")
13225  StopBodeEntry.insert(0,10000)
13226  EndFreq = 10000
13227  if FWRevOne > 2.16:
13228  if EndFreq >= 20000:
13229  Two_X_Sample.set(1)
13230  FBins = numpy.linspace(0, 100000, num=32768) #16384)
13231  else:
13232  Two_X_Sample.set(0)
13233  FBins = numpy.linspace(0, 50000, num=32768) #16384)
13234  ADC_Mux_Mode.set(0)
13235  SetADC_Mux()
13236  try:
13237  BeginFreq = float(StartBodeEntry.get())
13238  except:
13239  StartBodeEntry.delete(0,"end")
13240  StartBodeEntry.insert(0,100)
13241  BeginFreq = 100
13242  #
13243  if FSweepMode.get() == 1:
13244  if AWGAMode.get() == 2:
13245  AWGAMode.set(0) # Set AWG A to SVMI
13246  AWGAShape.set(18) # Set Shape to Sine
13247  if Two_X_Sample.get() == 1:
13248  AWGBIOMode.set(1)
13249  AWGBMode.set(0)
13250  else:
13251  AWGBMode.set(2) # Set AWG B to Hi-Z
13252  AWG_2X.set(0)
13253  BAWG2X()
13254  Reset_Freq = AWGAFreqEntry.get()
13255  if FSweepMode.get() == 2:
13256  if AWGBMode.get() == 2:
13257  AWGBMode.set(0) # Set AWG B to SVMI
13258  AWGBShape.set(18) # Set Shape to Sine
13259  if Two_X_Sample.get() == 1:
13260  AWGAIOMode.set(1)
13261  AWGAMode.set(0)
13262  else:
13263  AWGAMode.set(2) # Set AWG A to Hi-Z
13264  AWG_2X.set(0)
13265  BAWG2X()
13266  Reset_Freq = AWGBFreqEntry.get()
13267  if FSweepMode.get() == 3: # using external Minigen
13268  AWGAMode.set(2) # Set AWG A to Hi-Z
13269  AWGBMode.set(2) # Set AWG B to Hi-Z
13270  try:
13271  NSteps.set(float(SweepStepBodeEntry.get()))
13272  except:
13273  SweepStepBodeEntry.delete(0,"end")
13274  SweepStepBodeEntry.insert(0, NSteps.get())
13275  #
13276  if FSweepMode.get() > 0:
13277  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
13278  BAWGBModeLabel()
13279  LoopNum.set(1)
13280  NyquistFreq = SAMPLErate/2
13281  BeginIndex = int((BeginFreq/NyquistFreq)*32768)#16384)
13282  EndIndex = int((EndFreq/NyquistFreq)*32768)#16384)
13283  if NSteps.get() < 5:
13284  NSteps.set(5)
13285  if HScaleBP.get() == 1:
13286  LogFStop = math.log10(EndIndex)
13287  try:
13288  LogFStart = math.log10(BeginIndex)
13289  except:
13290  LogFStart = 0.1
13291  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
13292  else:
13293  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
13294 
13295  BStart()
13296  # UpdateBodeAll() # Always Update
13297 #
13298 def BStopBP():
13299  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
13300 
13301  if FSweepMode.get() == 1:
13302  AWGAFreqEntry.delete(0,"end")
13303  AWGAFreqEntry.insert(0, Reset_Freq)
13304  if FSweepMode.get() == 2:
13305  AWGBFreqEntry.delete(0,"end")
13306  AWGBFreqEntry.insert(0, Reset_Freq)
13307 #
13308  if (RUNstatus.get() == 1):
13309  RUNstatus.set(0)
13310  if AWGSync.get() == 0: # running in continuous mode
13311  session.cancel() # cancel continuous session mode while paused
13312  elif (RUNstatus.get() == 2):
13313  RUNstatus.set(3)
13314  elif (RUNstatus.get() == 3):
13315  RUNstatus.set(3)
13316  elif (RUNstatus.get() == 4):
13317  RUNstatus.set(3)
13318  UpdateBodeAll() # Always Update
13319 #
13321  global DBlevelBP
13322  global RUNstatus
13323 
13324  DBlevelBP.set(DBlevelBP.get() - 1)
13325 
13326  if RUNstatus.get() == 0: # Update if stopped
13327  UpdateBodeTrace()
13328 
13330  global DBlevelBP
13331  global RUNstatus
13332 
13333  DBlevelBP.set(DBlevelBP.get() + 1)
13334 
13335  if RUNstatus.get() == 0: # Update if stopped
13336  UpdateBodeTrace()
13337 
13339  global DBlevelBP
13340  global RUNstatus
13341 
13342  DBlevelBP.set(DBlevelBP.get() - 10)
13343 
13344  if RUNstatus.get() == 0: # Update if stopped
13345  UpdateBodeTrace()
13346 
13348  global DBlevelBP
13349  global RUNstatus
13350 
13351  DBlevelBP.set(DBlevelBP.get() + 10)
13352 
13353  if RUNstatus.get() == 0: # Update if stopped
13354  UpdateBodeTrace()
13355 
13357  global DBdivindexBP
13358  global RUNstatus
13359 
13360  if (DBdivindexBP.get() >= 1):
13361  DBdivindexBP.set(DBdivindexBP.get() - 1)
13362 
13363  if RUNstatus.get() == 0: # Update if stopped
13364  UpdateBodeTrace()
13365 
13367  global DBdivindexBP
13368  global DBdivlist
13369  global RUNstatus
13370 
13371  if (DBdivindexBP.get() < len(DBdivlist) - 1):
13372  DBdivindexBP.set(DBdivindexBP.get() + 1)
13373 
13374  if RUNstatus.get() == 0: # Update if stopped
13375  UpdateBodeTrace()
13376 #
13378  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
13379  ShowCA_VdB.set(1)
13380  ShowCA_P.set(1)
13381  ShowCB_VdB.set(1)
13382  ShowCB_P.set(1)
13383 
13385  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
13386  ShowCA_VdB.set(0)
13387  ShowCA_P.set(0)
13388  ShowCB_VdB.set(0)
13389  ShowCB_P.set(0)
13390 # Bode Plot refresh
13391 def UpdateBodeAll(): # Update Data, trace and screen
13392  global FFTBuffA, FFTBuffB
13393  global SMPfft
13394 
13395  # DoFFT() # Fast Fourier transformation
13396  MakeBodeTrace() # Update the traces
13397  UpdateBodeScreen() # Update the screen
13398 
13399 def UpdateBodeTrace(): # Update trace and screen
13400  MakeBodeTrace() # Update traces
13401  UpdateBodeScreen() # Update the screen
13402 
13403 def UpdateBodeScreen(): # Update screen with trace and text
13404  MakeBodeScreen() # Update the screen
13405 
13406 # ============================================ Freq Main routine ====================================================
13407 
13408 def UpdateFreqAll(): # Update Data, trace and screen
13409  global FFTBuffA, FFTBuffB
13410  global SMPfft
13411 
13412  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13413  return
13414 
13415  # DoFFT() # Fast Fourier transformation
13416  MakeFreqTrace() # Update the traces
13417  UpdateFreqScreen() # Update the screen
13418 
13419 def UpdateFreqTrace(): # Update trace and screen
13420  MakeFreqTrace() # Update traces
13421  UpdateFreqScreen() # Update the screen
13422 
13423 def UpdateFreqScreen(): # Update screen with trace and text
13424  MakeFreqScreen() # Update the screen
13425 
13426 def DoFFT(): # Fast Fourier transformation
13427  global FFTBuffA, FFTBuffB, AWGAwaveform, AWGBwaveform
13428  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowAWGASA, ShowAWGBSA
13429  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
13430  global FFTmemoryB, FFTresultB, FFTresultAWGA, FFTresultAWGB
13431  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
13432  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13433  global FFTwindowshape, FFTbandwidth
13434  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
13435  global SMPfft, LoopNum, IA_Ext_Conf
13436  global STARTsample, STOPsample, CutDC
13437  global TRACEaverage, FreqTraceMode, FSweepMode
13438  global TRACEresetFreq, ZEROstuffing
13439  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
13440  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13441  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesL
13442 
13443  # T1 = time.time() # For time measurement of FFT routine
13444  REX = []
13445  PhaseA = []
13446  PhaseB = []
13447  # Convert list to numpy array REX for faster Numpy calculations
13448  # Take the first fft samples
13449  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
13450 
13451  # Set Analog level display value MAX value is 5 volts for ALM1000
13452  REX = REX / 5.0
13453 
13454  # Do the FFT window function
13455  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
13456 
13457  # Zero stuffing of array for better interpolation of peak level of signals
13458  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13459  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13460 
13461  # Save previous trace in memory for max or average trace
13462  FFTmemoryA = FFTresultA
13463  if FreqTraceMode.get() == 3:
13464  PhaseMemoryA = PhaseA
13465 
13466  # FFT with numpy
13467  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13468  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
13469  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13470  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
13471 
13472  le = int(len(ALL) / 2) # Only half is used, other half is mirror
13473  # ALL = ALL[0:le] # So take only first half of the array
13474  FFTresultA = ALL[0:le]
13475  PhaseA = PhaseA[0:le]
13476  RMScorr = 1.0 / SMPfft # For VOLTAGE!
13477  Powcorr = 50*(RMScorr **2) # vpktage squared For POWER!
13478  FFTresultA = FFTresultA * Powcorr
13479 #
13480  REX = []
13481  # Convert list to numpy array REX for faster Numpy calculations
13482  # Take the first fft samples
13483  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
13484 
13485  # Set level display value MAX value is 5 volts for ALM1000
13486  REX = REX / 5.0
13487 
13488  # Do the FFT window function
13489  try:
13490  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13491  except:
13492  return
13493  # Zero stuffing of array for better interpolation of peak level of signals
13494  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13495  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13496 
13497  # Save previous trace in memory for max or average trace
13498  FFTmemoryB = FFTresultB
13499  if FreqTraceMode.get() == 3:
13500  PhaseMemoryB = PhaseB
13501  # FFT with numpy
13502  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13503  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13504  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13505  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13506 
13507  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13508  # ALL = ALL[0:le] # So take only first half of the array
13509  FFTresultB = ALL[0:le]
13510  PhaseB = PhaseB[0:le]
13511  FFTresultB = FFTresultB * Powcorr
13512 #
13513  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
13514  REX = []
13515  PhaseAB = []
13516  # Convert list to numpy array REX for faster Numpy calculations
13517  # Take the first fft samples
13518  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
13519 
13520  # Set level display value MAX value is 5 volts for ALM1000
13521  REX = REX / 5.0
13522 
13523  # Do the FFT window function
13524  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13525 
13526  # Zero stuffing of array for better interpolation of peak level of signals
13527  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13528  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13529 
13530  # Save previous trace in memory for max or average trace
13531  # FFTmemoryB = FFTresultB
13532  # if FreqTraceMode.get() == 3:
13533  # PhaseMemoryB = PhaseB
13534  # FFT with numpy
13535  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13536  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
13537  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13538  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13539 
13540  le = len(ALL) / 2 # Only half is used, other half is mirror
13541  #ALL = ALL[:le] # So take only first half of the array
13542  FFTresultAB = ALL[:le]
13543  PhaseAB = PhaseAB[:le]
13544  FFTresultAB = FFTresultAB * Powcorr
13545 #
13546  if ShowAWGASA.get() > 0:
13547  FFTAWGA = AWGAwaveform
13548  DCA = 0.0
13549  if CutDC.get() == 1:
13550  DCA = numpy.average(FFTAWGA)
13551  FFTAWGA = FFTAWGA - DCA
13552  if len(AWGAwaveform) < SMPfft:
13553  Repeats = math.ceil(SMPfft/len(AWGAwaveform))
13554  i = 0
13555  while i < Repeats:
13556  FFTAWGA = numpy.concatenate((FFTAWGA, AWGAwaveform-DCA))
13557  i = i + 1
13558  REX = []
13559  # Convert list to numpy array REX for faster Numpy calculations
13560  # Take the first fft samples
13561  REX = numpy.array(FFTAWGA[0:SMPfft]) # Make a numpy arry of the list
13562 
13563  # Set level display value MAX value is 5 volts for ALM1000
13564  REX = REX / 5.0
13565 
13566  # Do the FFT window function
13567  try:
13568  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13569  except:
13570  return
13571  # Zero stuffing of array for better interpolation of peak level of signals
13572  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13573  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13574  # FFT with numpy
13575  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13576  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13577  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13578  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13579 
13580  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13581  # ALL = ALL[0:le] # So take only first half of the array
13582  FFTresultAWGA = ALL[0:le]
13583  #PhaseB = PhaseB[0:le]
13584  FFTresultAWGA = FFTresultAWGA * Powcorr
13585 #
13586  if ShowAWGBSA.get() > 0:
13587  FFTAWGB = AWGBwaveform
13588  DCB = 0.0
13589  if CutDC.get() == 1:
13590  DCB = numpy.average(FFTAWGB)
13591  FFTAWGB = FFTAWGB - DCB
13592  if len(AWGBwaveform) < SMPfft:
13593  Repeats = math.ceil(SMPfft/len(AWGBwaveform))
13594  i = 1
13595  while i < Repeats:
13596  FFTAWGB = numpy.concatenate((FFTAWGB, AWGBwaveform-DCB))
13597  i = i + 1
13598  REX = []
13599  # Convert list to numpy array REX for faster Numpy calculations
13600  # Take the first fft samples
13601  REX = numpy.array(FFTAWGB[0:SMPfft]) # Make a numpy arry of the list
13602 
13603  # Set level display value MAX value is 5 volts for ALM1000
13604  REX = REX / 5.0
13605 
13606  # Do the FFT window function
13607  try:
13608  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13609  except:
13610  return
13611  # Zero stuffing of array for better interpolation of peak level of signals
13612  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13613  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13614  # FFT with numpy
13615  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13616  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13617  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13618  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13619 
13620  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13621  #ALL = ALL[0:le] # So take only first half of the array
13622  FFTresultAWGB = ALL[0:le]
13623  #PhaseB = PhaseB[0:le]
13624  FFTresultAWGB = FFTresultAWGB * Powcorr
13625 #
13626  TRACEsize = int(len(FFTresultB))
13627  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
13628  if SpectrumScreenStatus.get() > 0:
13629  try:
13630  StartFrequency = float(StartFreqEntry.get())
13631  except:
13632  StartFreqEntry.delete(0,"end")
13633  StartFreqEntry.insert(0,100)
13634  StartFrequency = 100
13635  STARTsample = int(StartFrequency / Fsample)
13636  else:
13637  STARTsample = 0
13638  if LoopNum.get() == 1:
13639  PhaseMemoryB = PhaseB
13640  FSweepAdB = []
13641  FSweepBdB = []
13642  FSweepAPh = []
13643  FSweepBPh = []
13644  if NetworkScreenStatus.get() > 0:
13645  NSweepSeriesR = []
13646  NSweepSeriesX = []
13647  NSweepSeriesMag = [] # in ohms
13648  NSweepSeriesAng = [] # in degrees
13649  NSweepParallelR = []
13650  NSweepParallelC = []
13651  NSweepParallelL = []
13652  NSweepSeriesC = []
13653  NSweepSeriesL = []
13654  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
13655  if FSweepMode.get() == 1:
13656  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13657  if ptmax > STARTsample:
13658  STARTsample = ptmax
13659  i = 0
13660  while i < 6:
13661  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13662  i = i + 1
13663  if FSweepMode.get() == 2:
13664  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13665  if ptmax > STARTsample:
13666  STARTsample = ptmax
13667  i = 0
13668  while i < 6:
13669  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13670  i = i + 1
13671 
13672  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
13673  if FSweepMode.get() == 1:
13674  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13675  if ptmax > STARTsample:
13676  STARTsample = ptmax
13677  i = 0
13678  while i < 6:
13679  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13680  i = i + 1
13681  if FSweepMode.get() == 2:
13682  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13683  if ptmax > STARTsample:
13684  STARTsample = ptmax
13685  i = 0
13686  while i < 6:
13687  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13688  i = i + 1
13689  if len(FFTresultB) == len(FFTmemoryB):
13690  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
13691  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
13692  try:
13693  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
13694  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
13695  except:
13696  FFTmemoryB = FFTresultB
13697  PhaseMemoryB = PhaseB
13698 #
13699  TRACEsize = int(len(FFTresultA))
13700  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
13701  if SpectrumScreenStatus.get() > 0:
13702  STARTsample = int(StartFrequency / Fsample)
13703  else:
13704  STARTsample = 0
13705  if LoopNum.get() == 1:
13706  PhaseMemoryA = PhaseA
13707  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
13708  if FSweepMode.get() == 1:
13709  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13710  if ptmax > STARTsample:
13711  STARTsample = ptmax
13712  i = 0
13713  while i < 6:
13714  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13715  i = i + 1
13716  if FSweepMode.get() == 2:
13717  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13718  if ptmax > STARTsample:
13719  STARTsample = ptmax
13720  i = 0
13721  while i < 6:
13722  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13723  i = i + 1
13724 
13725  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
13726  if FSweepMode.get() == 1:
13727  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13728  if ptmax > STARTsample:
13729  STARTsample = ptmax
13730  i = 0
13731  while i < 6:
13732  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13733  i = i + 1
13734  if FSweepMode.get() == 2:
13735  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13736  if ptmax > STARTsample:
13737  STARTsample = ptmax
13738  i = 0
13739  while i < 6:
13740  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13741  i = i + 1
13742 #
13743  if len(FFTresultA) == len(FFTmemoryA):
13744  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
13745  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
13746  try:
13747  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
13748  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
13749  except:
13750  FFTmemoryA = FFTresultA
13751  PhaseMemoryA = PhaseA
13752 #
13753  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
13754  FSweepAdB.append(numpy.amax(FFTresultA))
13755  FSweepBdB.append(numpy.amax(FFTresultB))
13756  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
13757  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
13758 
13759  TRACEresetFreq = False # Trace reset done
13760 
13761 def MakeFreqTrace(): # Update the grid and trace
13762  global FFTmemoryA, FFTresultA
13763  global FFTmemoryB, FFTresultB
13764  global FFTresultAWGA, FFTresultAWGB, ShowAWGASA, ShowAWGBSA
13765  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13766  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
13767  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
13768  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13769  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
13770  global PeakfreqA, PeakfreqB, Two_X_Sample
13771  global DBdivindex # Index value
13772  global DBdivlist # dB per division list
13773  global DBlevel # Reference level
13774  global GRHF,GRWF # Screenheight, Screenwidth
13775  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
13776  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
13777  global STARTsample, STOPsample, LoopNum, FSweepMode, FreqTraceMode, SMPfft
13778  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
13779  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline, TAFline, TBFline
13780  global Vdiv # Number of vertical divisions
13781  global X0LF, Y0TF # Left top X value, Left top Y value
13782 
13783  # Set the TRACEsize variable
13784  TRACEsize = 0
13785  try:
13786  StartFrequency = float(StartFreqEntry.get())
13787  except:
13788  StartFreqEntry.delete(0,"end")
13789  StartFreqEntry.insert(0,100)
13790  StartFrequency = 100
13791  try:
13792  StopFrequency = float(StopFreqEntry.get())
13793  except:
13794  StopFreqEntry.delete(0,"end")
13795  StopFreqEntry.insert(0,50000)
13796  StopFrequency = 50000
13797  if StartFrequency > StopFrequency :
13798  StopFreqEntry.delete(0,"end")
13799  StopFreqEntry.insert(0,50000)
13800  StopFrequency = 50000
13801  if StopFrequency < StartFrequency :
13802  StopFreqEntry.delete(0,"end")
13803  StopFreqEntry.insert(0,50000)
13804  StopFrequency = 50000
13805  try:
13806  Phasecenter = int(PhCenFreqEntry.get())
13807  RelPhaseCenter.set(Phasecenter)
13808  except:
13809  PhCenFreqEntry.delete(0,"end")
13810  PhCenFreqEntry.insert(0,0)
13811  RelPhaseCenter.set(0)
13812  Phasecenter = 0
13813  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
13814  if SAvertmaxEntry.get() == "10.0":
13815  SAvertmax = 10.0
13816  elif SAvertmaxEntry.get() == "1.0":
13817  SAvertmax = 1.0
13818  elif SAvertmaxEntry.get() == "0.1":
13819  SAvertmax = 0.1
13820  elif SAvertmaxEntry.get() == "10mV":
13821  SAvertmax = 1.0E-2
13822  elif SAvertmaxEntry.get() == "1mV":
13823  SAvertmax = 1.0E-3
13824  elif SAvertmaxEntry.get() == "100uV":
13825  SAvertmax = 1.0E-4
13826  elif SAvertmaxEntry.get() == "10uV":
13827  SAvertmax = 1.0E-5
13828  elif SAvertmaxEntry.get() == "1uV":
13829  SAvertmax = 1.0E-6
13830  elif SAvertmaxEntry.get() == "100nV":
13831  SAvertmax = 1.0E-7
13832  elif SAvertmaxEntry.get() == "10nV":
13833  SAvertmax = 1.0E-8
13834  else:
13835  SAvertmax = float(SAvertmaxEntry.get())
13836  if SAvertmax < 0.0: # negative values not allowed
13837  SAvertmaxEntry.delete(0,"end")
13838  SAvertmaxEntry.insert(0, "1mV")
13839  SAvertmax = 1.0E-3
13840  except:
13841  SAvertmaxEntry.delete(0,"end")
13842  SAvertmaxEntry.insert(0, "1mV")
13843  SAvertmax = 1.0E-3
13844  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
13845  if SAvertminEntry.get() == "10.0":
13846  SAvertmin = 10.0
13847  elif SAvertminEntry.get() == "1.0":
13848  SAvertmin = 1.0
13849  elif SAvertminEntry.get() == "0.1":
13850  SAvertmin = 0.1
13851  elif SAvertminEntry.get() == "10mV":
13852  SAvertmin = 1.0E-2
13853  elif SAvertminEntry.get() == "1mV":
13854  SAvertmin = 1.0E-3
13855  elif SAvertminEntry.get() == "100uV":
13856  SAvertmin = 1.0E-4
13857  elif SAvertminEntry.get() == "10uV":
13858  SAvertmin = 1.0E-5
13859  elif SAvertminEntry.get() == "1uV":
13860  SAvertmin = 1.0E-6
13861  elif SAvertminEntry.get() == "100nV":
13862  SAvertmin = 1.0E-7
13863  elif SAvertminEntry.get() == "10nV":
13864  SAvertmin = 1.0E-8
13865  else:
13866  SAvertmin = float(SAvertminEntry.get())
13867  if SAvertmin < 0.0: # negative values not allowed
13868  SAvertminEntry.delete(0,"end")
13869  SAvertminEntry.insert(0, "1uV")
13870  SAvertmin = 1.0E-6
13871  except:
13872  SAvertminEntry.delete(0,"end")
13873  SAvertminEntry.insert(0, "1uV")
13874  SAvertmin = 1.0E-6
13875  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
13876  TRACEsize = len(FFTresultA) # Set the trace length
13877  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
13878  TRACEsize = len(FFTresultB)
13879  elif ShowAWGASA.get() > 0:
13880  TRACEsize = len(FFTresultAWGA)
13881  elif ShowAWGBSA.get() > 0:
13882  TRACEsize = len(FFTresultAWGB)
13883  #print(TRACEsize)
13884  if TRACEsize == 0: # If no trace, skip rest of this routine
13885  return()
13886  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
13887  PhaseA = PhaseMemoryA
13888  PhaseB = PhaseMemoryB
13889  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
13890  # Vertical conversion factors (level dBs) and border limits
13891  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13892  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
13893  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13894  YVc = float(Y0TF) + YVconv * SAvertmax
13895  Ymin = Y0TF # Minimum position of screen grid (top)
13896  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
13897  Yphconv = float(GRHF) / 360
13898  Yp = float(Y0TF) + Yphconv + 180
13899  # Horizontal conversion factors (frequency Hz) and border limits
13900  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13901  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
13902  LogFStop = math.log10(StopFrequency)
13903  try:
13904  LogFStart = math.log10(StartFrequency)
13905  except:
13906  LogFStart = 0.0
13907  LogFpixel = (LogFStop - LogFStart) / GRWF
13908  #
13909  try:
13910  LogVStop = math.log10(SAvertmax)
13911  except:
13912  LogVStop = 0.0
13913  try:
13914  LogVStart = math.log10(SAvertmin)
13915  except:
13916  LogVStart = -10
13917  LogVpixel = (LogVStop - LogVStart) / GRHF
13918  #
13919  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
13920  STARTsample = int(math.ceil(STARTsample)) # First within screen range
13921 
13922  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
13923  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
13924 
13925  MAXsample = TRACEsize # Just an out of range check
13926  if STARTsample > (MAXsample - 1):
13927  STARTsample = MAXsample - 1
13928 
13929  if STOPsample > MAXsample:
13930  STOPsample = MAXsample
13931 
13932  T1Fline = []
13933  T2Fline = []
13934  TAFline = []
13935  TBFline = []
13936  T1Pline = []
13937  T2Pline = []
13938  TFMline = []
13939  n = STARTsample
13940  PeakIndexA = PeakIndexB = n
13941  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
13942  while n <= STOPsample:
13943  F = n * Fsample
13944  if HScale.get() == 1:
13945  try:
13946  LogF = math.log10(F) # convet to log Freq
13947  x = X0LF + (LogF - LogFStart)/LogFpixel
13948  except:
13949  x = X0LF
13950  else:
13951  x = X0LF + (F - StartFrequency) / Fpixel
13952  if ShowC1_VdB.get() == 1:
13953  T1Fline.append(int(x + 0.5))
13954  try:
13955  if SAVScale.get() == 0:
13956  if SAVPSD.get() == 1:
13957  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth))
13958  else:
13959  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
13960  ya = Yc - Yconv * dbA
13961  else:
13962  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
13963  V = 10.0**(dbA/20.0)# convert back to RMS Volts
13964  if SAVPSD.get() == 1:
13965  V = V/math.sqrt(FBinWidth) # per root Hz
13966  if SAVScale.get() == 2:
13967  try:
13968  LogV = math.log10(V) # convet to log Volts
13969  ya = YVc - (LogV - LogVStart)/LogVpixel
13970  except:
13971  ya = YVc - YVconv * V
13972  else:
13973  ya = YVc - YVconv * V
13974  except:
13975  ya = Ymax
13976  if (ya < Ymin):
13977  ya = Ymin
13978  if (ya > Ymax):
13979  ya = Ymax
13980  if dbA > PeakdbA:
13981  PeakdbA = dbA
13982  PeakyA = int(ya + 0.5)
13983  PeakxA = int(x + 0.5)
13984  PeakfreqA = F
13985  PeakIndexA = n
13986  T1Fline.append(int(ya + 0.5))
13987  if ShowC2_VdB.get() == 1:
13988  T2Fline.append(int(x + 0.5))
13989  try:
13990  if SAVScale.get() == 0:
13991  if SAVPSD.get() == 1:
13992  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
13993  else:
13994  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
13995  yb = Yc - Yconv * dbB
13996  else:
13997  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
13998  V = 10.0**(dbB/20.0)# RMS Volts
13999  if SAVPSD.get() == 1:
14000  V = V/math.sqrt(FBinWidth) # per root Hz
14001  if SAVScale.get() == 2:
14002  try:
14003  LogV = math.log10(V) # convet to log Volts
14004  yb = YVc - (LogV - LogVStart)/LogVpixel
14005  except:
14006  yb = YVc - YVconv * V
14007  else:
14008  yb = YVc - YVconv * V
14009  except:
14010  yb = Ymax
14011  if (yb < Ymin):
14012  yb = Ymin
14013  if (yb > Ymax):
14014  yb = Ymax
14015  if dbB > PeakdbB:
14016  PeakdbB = dbB
14017  PeakyB = int(yb + 0.5)
14018  PeakxB = int(x + 0.5)
14019  PeakfreqB = F
14020  PeakIndexB = n
14021  T2Fline.append(int(yb + 0.5))
14022  if ShowAWGASA.get() > 0:
14023  TAFline.append(int(x + 0.5))
14024  try:
14025  if SAVPSD.get() == 1:
14026  dbA = 10 * math.log10(float(FFTresultAWGA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14027  else:
14028  dbA = 10 * math.log10(float(FFTresultAWGA[n])) # Convert power to DBs
14029  ya = Yc - Yconv * dbA
14030  except:
14031  ya = Ymax
14032  if (ya < Ymin):
14033  ya = Ymin
14034  if (ya > Ymax):
14035  ya = Ymax
14036  TAFline.append(int(ya + 0.5))
14037  if ShowAWGBSA.get() > 0:
14038  TBFline.append(int(x + 0.5))
14039  try:
14040  if SAVPSD.get() == 1:
14041  dbA = 10 * math.log10(float(FFTresultAWGB[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14042  else:
14043  dbA = 10 * math.log10(float(FFTresultAWGb[n])) # Convert power to DBs
14044  ya = Yc - Yconv * dbA
14045  except:
14046  ya = Ymax
14047  if (ya < Ymin):
14048  ya = Ymin
14049  if (ya > Ymax):
14050  ya = Ymax
14051  TBFline.append(int(ya + 0.5))
14052  if ShowC1_P.get() == 1:
14053  T1Pline.append(int(x + 0.5))
14054  if FSweepMode.get() > 0:
14055  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
14056  else:
14057  RelPhase = PhaseA[n]-PhaseB[n]
14058  RelPhase = RelPhase - Phasecenter
14059  if RelPhase > 180:
14060  RelPhase = RelPhase - 360
14061  elif RelPhase < -180:
14062  RelPhase = RelPhase + 360
14063  if Two_X_Sample.get() == 0:
14064  PhErr = 0.0018 * n * Fsample # calculate phase error due half sample period offset
14065  RelPhase = RelPhase + PhErr - 12.0
14066  else:
14067  RelPhase = RelPhase - 9.0
14068  ya = Yp - Yphconv * RelPhase
14069  T1Pline.append(int(ya + 0.5))
14070  if ShowC2_P.get() == 1:
14071  T2Pline.append(int(x + 0.5))
14072  if FSweepMode.get() > 0:
14073  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
14074  else:
14075  RelPhase = PhaseB[n]-PhaseA[n]
14076  RelPhase = RelPhase - Phasecenter
14077  if RelPhase > 180:
14078  RelPhase = RelPhase - 360
14079  elif RelPhase < -180:
14080  RelPhase = RelPhase + 360
14081  if Two_X_Sample.get() == 0:
14082  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14083  RelPhase = RelPhase - PhErr - 12.0
14084  else:
14085  RelPhase = RelPhase - 9.0
14086  ya = Yp - Yphconv * RelPhase
14087  T2Pline.append(int(ya + 0.5))
14088  if ShowMathSA.get() > 0:
14089  TFMline.append(int(x + 0.5))
14090  if SAVPSD.get() == 1:
14091  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14092  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14093  else:
14094  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14095  dbB = 10 * math.log10(float(FFTresultB[n]))
14096  if ShowMathSA.get() == 1:
14097  MdB = dbA - dbB
14098  elif ShowMathSA.get() == 2:
14099  MdB = dbB - dbA
14100  yb = Yc - Yconv * MdB
14101  if (yb < Ymin):
14102  yb = Ymin
14103  if (yb > Ymax):
14104  yb = Ymax
14105  if MdB > PeakMdb:
14106  PeakMdb = MdB
14107  PeakyM = int(yb + 0.5)
14108  PeakxM = int(x + 0.5)
14109  PeakfreqM = F
14110  TFMline.append(int(yb + 0.5))
14111  n = n + 1
14112 #
14113 # make Bode Plot Traces
14114 def MakeBodeTrace(): # Update the grid and trace
14115  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
14116  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
14117  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14118  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14119  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
14120  global DBdivindexBP # Index value
14121  global DBdivlist # dB per division list
14122  global DBlevelBP # Reference level
14123  global GRHBP # Screenheight
14124  global GRWBP # Screenwidth
14125  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
14126  global StartBodeEntry, StopBodeEntry, SMPfft
14127  global STARTsample, STOPsample, LoopNum, FSweepMode
14128  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14129  global TAFline, TBFline, TBPMline, TAPline, TBPline
14130  global Vdiv # Number of vertical divisions
14131  global X0LBP # Left top X value
14132  global Y0TBP # Left top Y value
14133  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
14134  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
14135  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14136 
14137  # Set the TRACEsize variable
14138  TRACEsize = 0
14139  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
14140  TRACEsize = len(FStep) # Set the trace length
14141  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
14142  TRACEsize = len(FStep)
14143  if TRACEsize == 0: # If no trace, skip rest of this routine
14144  return()
14145  #
14146  try:
14147  EndFreq = float(StopBodeEntry.get())
14148  except:
14149  StopBodeEntry.delete(0,"end")
14150  StopBodeEntry.insert(0,10000)
14151  EndFreq = 10000
14152  try:
14153  BeginFreq = float(StartBodeEntry.get())
14154  except:
14155  StartBodeEntry.delete(0,"end")
14156  StartBodeEntry.insert(0,100)
14157  BeginFreq = 100
14158  try:
14159  Phasecenter = float(PhCenBodeEntry.get())
14160  RelPhaseCenter.set(Phasecenter)
14161  except:
14162  PhCenBodeEntry.delete(0,"end")
14163  PhCenBodeEntry.insert(0,0)
14164  RelPhaseCenter.set(0)
14165  Phasecenter = 0
14166  try:
14167  Impedcenter = float(ImCenBodeEntry.get())
14168  ImpedanceCenter.set(Impedcenter)
14169  except:
14170  ImCenBodeEntry.delete(0,"end")
14171  ImCenBodeEntry.insert(0,0)
14172  ImpedanceCenter.set(0)
14173  Impedcenter = 0
14174  #
14175  HalfSAMPLErate = SAMPLErate/2
14176  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
14177  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
14178  CurrentFreqX = X0LBP + 14
14179  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
14180  # Vertical conversion factors (level dBs) and border limits
14181  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14182  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14183  Ymin = Y0TBP # Minimum position of screen grid (top)
14184  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
14185  Yphconv = float(GRHBP) / 360 # degrees per pixel
14186  Yp = float(Y0TBP) + Yphconv + 180
14187  x1 = X0LBP + 14
14188  # Horizontal conversion factors (frequency Hz) and border limits
14189  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14190  LogFStop = math.log10(EndFreq)
14191  try:
14192  LogFStart = math.log10(BeginFreq)
14193  except:
14194  LogFStart = 0.0
14195  LogFpixel = (LogFStop - LogFStart) / GRWBP
14196  TAFline = []
14197  TBFline = []
14198  TAPline = []
14199  TBPline = []
14200  TIARline = []
14201  TIAXline = []
14202  TIAMagline = []
14203  TIAAngline = []
14204  TBPMline = []
14205  PeakdbA = -200
14206  PeakdbB = -200
14207  PeakMdb = -200
14208  n = 0
14209  for n in range(len(FSweepAdB)): # while n < len(FStep):
14210  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14211  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14212  else:
14213  F = FBins[int(FStep[0])]
14214  if F >= BeginFreq and F <= EndFreq:
14215  if HScaleBP.get() == 1:
14216  try:
14217  LogF = math.log10(F) # convet to log Freq
14218  x = x1 + (LogF - LogFStart)/LogFpixel
14219  except:
14220  x = x1
14221  else:
14222  x = x1 + (F - BeginFreq) / Fpixel
14223  CurrentFreqX = x
14224  if ShowCA_VdB.get() == 1:
14225  TAFline.append(int(x + 0.5))
14226  try:
14227  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14228  ya = Yc - Yconv * dbA
14229  except:
14230  ya = Ymax
14231  if (ya < Ymin):
14232  ya = Ymin
14233  if (ya > Ymax):
14234  ya = Ymax
14235  if dbA > PeakdbA:
14236  PeakdbA = dbA
14237  PeakyA = int(ya + 0.5)
14238  PeakxA = int(x + 0.5)
14239  PeakfreqA = F
14240  TAFline.append(int(ya + 0.5))
14241  if ShowCB_VdB.get() == 1:
14242  TBFline.append(int(x + 0.5))
14243  try:
14244  dbB = 10 * math.log10(float(FSweepBdB[n]))
14245  yb = Yc - Yconv * dbB
14246  except:
14247  yb = Ymax
14248  if (yb < Ymin):
14249  yb = Ymin
14250  if (yb > Ymax):
14251  yb = Ymax
14252  if dbB > PeakdbB:
14253  PeakdbB = dbB
14254  PeakyB = int(yb + 0.5)
14255  PeakxB = int(x + 0.5)
14256  PeakfreqB = F
14257  TBFline.append(int(yb + 0.5))
14258  if ShowCA_P.get() == 1:
14259  TAPline.append(int(x + 0.5))
14260  RelPhase = FSweepAPh[n] - FSweepBPh[n]
14261  RelPhase = RelPhase - Phasecenter
14262  if RelPhase > 180:
14263  RelPhase = RelPhase - 360
14264  elif RelPhase < -180:
14265  RelPhase = RelPhase + 360
14266  if Two_X_Sample.get() == 0:
14267  PhErr = 0.0018 * F # calculate phase error due half sample period offset
14268  RelPhase = RelPhase + PhErr - PhaseOffset1x
14269  else:
14270  RelPhase = RelPhase - PhaseOffset2x
14271  ya = Yp - Yphconv * RelPhase
14272  TAPline.append(int(ya + 0.5))
14273  if ShowCB_P.get() == 1:
14274  TBPline.append(int(x + 0.5))
14275  RelPhase = FSweepBPh[n] - FSweepAPh[n]
14276  RelPhase = RelPhase - Phasecenter
14277  if RelPhase > 180:
14278  RelPhase = RelPhase - 360
14279  elif RelPhase < -180:
14280  RelPhase = RelPhase + 360
14281  if Two_X_Sample.get() == 0:
14282  PhErr = 0.0018 * F # calculate phase error due half sample period offset
14283  RelPhase = RelPhase - PhErr - PhaseOffset1x
14284  else:
14285  RelPhase = RelPhase - PhaseOffset2x
14286  ya = Yp - Yphconv * RelPhase
14287  TBPline.append(int(ya + 0.5))
14288  if ShowMathBP.get() > 0:
14289  TBPMline.append(int(x + 0.5))
14290  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14291  dbB = 10 * math.log10(float(FSweepBdB[n]))
14292  if ShowMathBP.get() == 1:
14293  MdB = dbA - dbB
14294  elif ShowMathBP.get() == 2:
14295  MdB = dbB - dbA
14296  yb = Yc - Yconv * MdB
14297  if (yb < Ymin):
14298  yb = Ymin
14299  if (yb > Ymax):
14300  yb = Ymax
14301  if MdB > PeakMdb:
14302  PeakMdb = MdB
14303  PeakyM = int(yb + 0.5)
14304  PeakxM = int(x + 0.5)
14305  PeakfreqM = F
14306  TBPMline.append(int(yb + 0.5))
14307 # draw impedance trace if necessary
14308  if NetworkScreenStatus.get() > 0:
14309  ycenter = Y0TBP + (GRHBP/2)
14310  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
14311  n = 0
14312  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
14313  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14314  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14315  else:
14316  F = FBins[int(FStep[0])]
14317  if F >= BeginFreq and F <= EndFreq:
14318  if HScaleBP.get() == 1:
14319  try:
14320  LogF = math.log10(F) # convet to log Freq
14321  x = x1 + (LogF - LogFStart)/LogFpixel
14322  except:
14323  x = x1
14324  else:
14325  x = x1 + (F - BeginFreq) / Fpixel
14326  if Show_Rseries.get() == 1:
14327  TIARline.append(int(x + 0.5))
14328  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
14329  if (y1 < Ymin):
14330  y1 = Ymin
14331  if (y1 > Ymax):
14332  y1 = Ymax
14333  TIARline.append(y1)
14334  if Show_Xseries.get() == 1:
14335  TIAXline.append(int(x + 0.5))
14336  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
14337  if (y1 < Ymin):
14338  y1 = Ymin
14339  if (y1 > Ymax):
14340  y1 = Ymax
14341  TIAXline.append(y1)
14342  if Show_Magnitude.get() == 1:
14343  TIAMagline.append(int(x + 0.5))
14344  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
14345  if (y1 < Ymin):
14346  y1 = Ymin
14347  if (y1 > Ymax):
14348  y1 = Ymax
14349  TIAMagline.append(y1)
14350  if Show_Angle.get() == 1:
14351  TIAAngline.append(int(x + 0.5))
14352  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
14353  if (y1 < Ymin):
14354  y1 = Ymin
14355  if (y1 > Ymax):
14356  y1 = Ymax
14357  TIAAngline.append(y1)
14358 #
14359 def MakeBodeScreen(): # Update the screen with traces and text
14360  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
14361  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14362  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14363  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
14364  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
14365  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
14366  global COLORgrid # The colors
14367  global COLORsignalband, COLORtext
14368  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
14369  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
14370  global DBdivindexBP # Index value
14371  global DBdivlist # dB per division list
14372  global DBlevelBP # Reference level
14373  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14374  global X0LBP # Left top X value
14375  global Y0TBP # Left top Y value
14376  global GRWBP # Screenwidth
14377  global GRHBP # Screenheight
14378  global FontSize
14379  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14380  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
14381  global SMPfft # number of FFT samples
14382  global StartBodeEntry, StopBodeEntry
14383  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
14384  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
14385  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14386  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
14387  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
14388  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
14389  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
14390  global TAPRline, TBPRline
14391  global TRACEaverage # Number of traces for averageing
14392  global FreqTraceMode # 1 normal 2 max 3 average
14393  global Vdiv, ResScale # Number of vertical divisions
14394  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14395  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
14396 
14397  # Delete all items on the screen
14398  MarkerFreqNum = 0
14399  Bodeca.delete(ALL) # remove all items
14400 
14401  try:
14402  EndFreq = float(StopBodeEntry.get())
14403  except:
14404  StopBodeEntry.delete(0,"end")
14405  StopBodeEntry.insert(0,10000)
14406  EndFreq = 10000
14407  try:
14408  BeginFreq = float(StartBodeEntry.get())
14409  except:
14410  StartBodeEntry.delete(0,"end")
14411  StartBodeEntry.insert(0,100)
14412  BeginFreq = 100
14413  try:
14414  Phasecenter = float(PhCenBodeEntry.get())
14415  RelPhaseCenter.set(Phasecenter)
14416  except:
14417  PhCenBodeEntry.delete(0,"end")
14418  PhCenBodeEntry.insert(0,0)
14419  RelPhaseCenter.set(0)
14420  Phasecenter = 0
14421  try:
14422  Impedcenter = float(ImCenBodeEntry.get())
14423  ImpedanceCenter.set(Impedcenter)
14424  except:
14425  ImCenBodeEntry.delete(0,"end")
14426  ImCenBodeEntry.insert(0,0)
14427  ImpedanceCenter.set(0)
14428  Impedcenter = 0
14429  #
14430  # Draw horizontal grid lines
14431  i = 0
14432  x1 = X0LBP + 14
14433  x2 = x1 + GRWBP
14434  while (i <= Vdiv.get()):
14435  y = Y0TBP + i * GRHBP/Vdiv.get()
14436  Dline = [x1,y,x2,y]
14437  if i == 0 or i == Vdiv.get():
14438  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14439  else:
14440  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14441  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
14442  Vaxis_label = str(Vaxis_value)
14443  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
14444  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
14445  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
14446  Vaxis_label = str(Vaxis_value)
14447  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
14448  if NetworkScreenStatus.get() > 0:
14449  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
14450  RperDiv = float(ResScale.get())
14451  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
14452  if Vaxis_value > 500 or Vaxis_value < -500:
14453  Vaxis_value = Vaxis_value/1000.0
14454  if Vaxis_value > 5 or Vaxis_value < -5:
14455  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
14456  else:
14457  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
14458  elif Vaxis_value > 50 or Vaxis_value < -50:
14459  Vaxis_label = ' {0:.1f} '.format(Vaxis_value)
14460  elif Vaxis_value > 5 or Vaxis_value < -55:
14461  Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
14462  else:
14463  Vaxis_label = ' {0:.3f} '.format(Vaxis_value)
14464  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
14465  i = i + 1
14466  # Draw vertical grid lines
14467  i = 0
14468  y1 = Y0TBP
14469  y2 = Y0TBP + GRHBP
14470  if HScaleBP.get() == 1:
14471  F = 1.0
14472  LogFStop = math.log10(EndFreq)
14473  try:
14474  LogFStart = math.log10(BeginFreq)
14475  except:
14476  LogFStart = 0.0
14477  LogFpixel = (LogFStop - LogFStart) / GRWBP
14478  # draw left and right edges
14479  while F <= EndFreq:
14480  if F >= BeginFreq:
14481  try:
14482  LogF = math.log10(F) # convet to log Freq
14483  x = x1 + (LogF - LogFStart)/LogFpixel
14484  except:
14485  x = x1
14486  Dline = [x,y1,x,y2]
14487  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
14488  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14489  axis_label = str(F)
14490  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
14491  else:
14492  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14493 
14494  if F < 10:
14495  F = F + 1
14496  elif F < 100:
14497  F = F + 10
14498  elif F < 1000:
14499  F = F + 100
14500  elif F < 1000:
14501  F = F + 100
14502  elif F < 10000:
14503  F = F + 1000
14504  elif F < 100000:
14505  F = F + 10000
14506  elif F < 200000:
14507  F = F + 10000
14508  else:
14509  Freqdiv = (EndFreq - BeginFreq) / 10
14510  while (i < 11):
14511  x = x1 + i * GRWBP/10
14512  Dline = [x,y1,x,y2]
14513  if i == 0 or i == 10:
14514  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14515  else:
14516  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14517  axis_value = BeginFreq + (i * Freqdiv)
14518  axis_label = str(axis_value)
14519  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
14520  i = i + 1
14521  # Draw X - Y cursors if needed
14522  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14523  LogFStop = math.log10(EndFreq)
14524  try:
14525  LogFStart = math.log10(BeginFreq)
14526  except:
14527  LogFStart = 0.0
14528  LogFpixel = (LogFStop - LogFStart) / GRWBP
14529  if ShowBPCur.get() > 0:
14530  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
14531  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
14532  # Horizontal conversion factors (frequency Hz) and border limits
14533  if HScaleBP.get() == 1:
14534  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
14535  else:
14536  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
14537  XFString = ' {0:.2f} '.format(xfreq)
14538  V_label = XFString + " Hz"
14539  Bodeca.create_text(BPCursor, Y0TBP+GRHBP+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
14540  #Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14541 #
14542  if ShowBdBCur.get() > 0:
14543  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
14544  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
14545  if ShowBdBCur.get() == 1:
14546  # Vertical conversion factors (level dBs) and border limits
14547  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14548  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14549  yvdB = ((Yc-BdBCursor)/Yconv)
14550  VdBString = ' {0:.1f} '.format(yvdB)
14551  V_label = VdBString + " dBV"
14552  else:
14553  # Vertical conversion factors (level degrees) and border limits
14554  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
14555  Yc = float(Y0TBP) # Yc is the 180 degree position
14556  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
14557  VdBString = ' {0:.1f} '.format(yvdB)
14558  V_label = VdBString + " Deg"
14559  Bodeca.create_text(x1+GRWBP+1, BdBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14560  #Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14561  #
14562  SmoothBool = SmoothCurvesBP.get()
14563  # Draw traces
14564  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
14565  # Write the trace CHA
14566  if OverRangeFlagA == 1:
14567  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14568  else:
14569  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14570  if ShowMarkerBP.get() == 1:
14571  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
14572  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
14573  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
14574  # Write the trace CHB
14575  if OverRangeFlagB == 1:
14576  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14577  else:
14578  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14579  if ShowMarkerBP.get() == 1:
14580  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
14581  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
14582  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
14583  # Write the phase trace A-B
14584  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14585  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
14586  # Write the phase trace A-B
14587  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14588  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
14589  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14590  if ShowMarkerBP.get() == 1:
14591  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
14592  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
14593  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
14594  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14595  if ShowMarkerBP.get() == 1:
14596  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
14597  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
14598  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
14599  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14600  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
14601  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14602  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
14603  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14604  if ShowMarkerBP.get() == 1:
14605  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
14606  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
14607  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
14608  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14609  if ShowMarkerBP.get() == 1:
14610  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
14611  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
14612  if Show_Rseries.get() == 1 and len(TIARline) > 4:
14613  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14614  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
14615  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14616  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
14617  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14618  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
14619  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14620  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
14621  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14622  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
14623  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14624  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
14625  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14626  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
14627  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14628 
14629  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
14630  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
14631  if HScaleBP.get() == 1:
14632  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
14633  else:
14634  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
14635  XFString = ' {0:.0f} '.format(xfreq)
14636  V_label = XFString + " Hz"
14637  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
14638  # General information on top of the grid
14639 
14640  txt = " Sample rate: " + str(SAMPLErate)
14641  txt = txt + " FFT samples: " + str(SMPfft)
14642 
14643  txt = txt + " " + FFTwindowname
14644 
14645  x = X0LBP
14646  y = 12
14647  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14648 
14649  # Start and stop frequency and dB/div and trace mode
14650  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
14651  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
14652  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
14653  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
14654 
14655  x = X0LBP
14656  y = Y0TBP+GRHBP+23
14657  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14658 
14659  if FreqTraceMode.get() == 1:
14660  txt ="Normal mode "
14661 
14662  if FreqTraceMode.get() == 2:
14663  txt = "Peak hold mode "
14664 
14665  if FreqTraceMode.get() == 3:
14666  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
14667 
14668  if ZEROstuffing.get() > 0:
14669  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
14670  # Runstatus and level information
14671  if (RUNstatus.get() == 0):
14672  txt = txt + " Stopped "
14673  else:
14674  if BodeDisp.get() == 1:
14675  txt = txt + " Running "
14676  else:
14677  txt = txt + " Display off "
14678  if FSweepMode.get() > 0:
14679  txt = txt + " Freq Step = " + str(LoopNum.get())
14680  x = X0LBP
14681  y = Y0TBP+GRHBP+34
14682  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14683 
14684 # Impedance analyzer routines -----
14685 def UpdateIAAll(): # Update Data, trace and screen
14686  global FFTBuffA, FFTBuffB
14687  global SMPfft
14688 
14689  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
14690  return
14691 
14692  MakeIATrace() # Update the traces
14693  UpdateIAScreen() # Update the screen
14694 
14695 def UpdateIATrace(): # Update trace and screen
14696  MakeIATrace() # Update traces
14697  UpdateIAScreen() # Update the screen
14698 
14699 def UpdateIAScreen(): # Update screen with trace and text
14700  MakeIAScreen() # Update the screen
14701  root.update() # Activate updated screens
14702 #
14704 
14705 # Input Variables
14706  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
14707  #(VZ/VA)from vector voltmeter
14708  # global VVangle # angle in degrees between VZ and VA
14709  global RsystemEntry # resistance of series resistor or power divider
14710 # Computed outputs
14711  # global VVangleCosine # cosine of vector voltmeter angle
14712  global ImpedanceMagnitude # in ohms
14713  global ImpedanceAngle # in degrees
14714  global ImpedanceRseries, ImpedanceXseries # in ohms
14715  global IA_Ext_Conf
14716 
14717  DEG2RAD = (math.pi / 180.0)
14718  SMALL = 1E-20
14719  try:
14720  ResValue = float(RsystemEntry.get())
14721  except:
14722  ResValue = 1000.0
14723 
14724  VA = math.pow(10,(PeakdbA/20))
14725  VB = math.pow(10,(PeakdbB/20))
14726  VVangleCosine = math.cos(math.radians(PeakRelPhase))
14727  if IA_Ext_Conf.get() == 1:
14728  VAB = math.pow(10,(PeakdbAB/20))
14729  VZ = VAB # VZ=VA-VB
14730  # VI = VB
14731  else:
14732  VZ = VB # VZ=VB
14733  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
14734  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
14735  Za = ResValue * VA / VI
14736  ImpedanceRseries = Za * costheta - ResValue
14737  ImpedanceMagnitude = ResValue * VZ / VI
14738  # don't try to take square root of a negative number)
14739  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
14740 
14741  if(PeakRelPhase < 0.0):
14742  ImpedanceXseries = -ImpedanceXseries
14743  if IA_Ext_Conf.get() == 1:
14744  ImpedanceRseries = -ImpedanceRseries
14745  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
14746 #
14747 def MakeIATrace(): # Update the grid and trace
14748  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
14749  global FFTmemoryB, FFTresultB
14750  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14751  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
14752  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
14753  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
14754  global DBdivindex # Index value
14755  global DBdivlist # dB per division list
14756  global DBlevel # Reference level
14757  global GRHIA # Screenheight
14758  global GRWIA # Screenwidth
14759  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SMPfft
14760  global STARTsample, STOPsample, LoopNum, FSweepMode
14761  global TRACEmode, Two_X_Sample, IA_Ext_Conf
14762  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
14763  global Vdiv # Number of vertical divisions
14764  global X0LIA # Left top X value
14765  global Y0TIA # Left top Y value
14766  global ImpedanceMagnitude # in ohms
14767  global ImpedanceAngle # in degrees
14768  global ImpedanceRseries, ImpedanceXseries # in ohms
14769 
14770  # Set the TRACEsize variable
14771  TRACEsize = len(FFTresultA) # Set the trace length
14772  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
14773  # Horizontal conversion factors (frequency Hz) and border limits
14774  STARTsample = 0 # First sample in FFTresult[] that is used
14775  STARTsample = int(math.ceil(STARTsample)) # First within screen range
14776  if Two_X_Sample.get() == 0:
14777  STOPsample = 45000 / Fsample # Last sample in FFTresult[] that is used
14778  else:
14779  STOPsample = 90000 / Fsample
14780  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
14781 #
14782  RMScorr = 1.0 / SMPfft # For VOLTAGE!
14783  Powcorr = RMScorr **2 # vpktage squared For POWER!
14784  try:
14785  GainCorrection = float(eval(GainCorEntry.get()))
14786  except:
14787  GainCorEntry.delete(0,END)
14788  GainCorEntry.insert(0, GainCorrection)
14789 
14790  try:
14791  PhaseCorrection = float(eval(PhaseCorEntry.get()))
14792  except:
14793  PhaseCorEntry.delete(0,END)
14794  PhaseCorEntry.insert(0, PhaseCorrection)
14795 
14796  MAXsample = TRACEsize # Just an out of range check
14797  if STARTsample > (MAXsample - 1):
14798  STARTsample = MAXsample - 1
14799 
14800  if STOPsample > MAXsample:
14801  STOPsample = MAXsample
14802 
14803  n = STARTsample
14804  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
14805  PeakphaseA = PhaseA[n]
14806  PeakphaseB = PhaseB[n]
14807  #PeakphaseAB = PhaseAB[n]
14808  PeakSample = n
14809 
14810  PeakdbA = 10 * math.log10(float(FFTresultA[n]))
14811  PeakdbB = 10 * math.log10(float(FFTresultB[n]))
14812  PeakMdb = PeakdbA - PeakdbB
14813  if IA_Ext_Conf.get() == 1:
14814  PeakdbAB = 10 * math.log10(float(FFTresultAB[n]))
14815  while n <= STOPsample:
14816  F = n * Fsample
14817  try:
14818  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs, except for log(0) error
14819  except:
14820  dbA = -200
14821  if dbA > PeakdbA:
14822  PeakdbA = dbA
14823  PeakfreqA = F
14824  PeakphaseA = PhaseA[n]
14825  PeakSample = n
14826 
14827  try:
14828  dbB = 10 * math.log10(float(FFTresultB[n]))
14829  except:
14830  dbB = -200
14831  if dbB > PeakdbB:
14832  PeakdbB = dbB
14833  PeakfreqB = F
14834  PeakphaseB = PhaseB[n]
14835 
14836  if IA_Ext_Conf.get() == 1:
14837  try:
14838  dbAB = 10 * math.log10(float(FFTresultAB[n]))
14839  except:
14840  dbAB = -200
14841  if dbAB > PeakdbAB:
14842  PeakdbAB = dbAB
14843  PeakphaseAB = PhaseAB[n]
14844  RelPhase = PhaseA[n]-PhaseB[n]
14845  if RelPhase > 180:
14846  RelPhase = RelPhase - 360
14847  elif RelPhase < -180:
14848  RelPhase = RelPhase + 360
14849  if Two_X_Sample.get() == 0:
14850  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14851  RelPhase = RelPhase + PhErr - 12.0
14852  else:
14853  RelPhase = RelPhase - 9.0
14854  n = n + 1
14855  if IA_Ext_Conf.get() == 1:
14856  PeakRelPhase = PeakphaseAB-PeakphaseA
14857  else:
14858  PeakRelPhase = PeakphaseB-PeakphaseA
14859 #
14860  if PeakRelPhase > 180:
14861  PeakRelPhase = PeakRelPhase - 360
14862  elif PeakRelPhase < -180:
14863  PeakRelPhase = PeakRelPhase + 360
14864  if Two_X_Sample.get() == 0:
14865  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
14866  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
14867  else:
14868  PeakRelPhase = PeakRelPhase + PhaseCorrection
14869  PeakdbB = PeakdbB + GainCorrection
14870  DoImpedance()
14871 
14873 def MakeIAScreen(): # Update the screen with traces and text
14874  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
14875  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14876  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
14877  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
14878  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
14879  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
14880  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry, CapZeroEntry
14881  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
14882  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
14883  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
14884  global ResScale, DisplaySeries # Ohms per div
14885  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14886  global X0LIA # Left top X value
14887  global Y0TIA # Left top Y value
14888  global GRWIA # Screenwidth
14889  global GRHIA # Screenheight
14890  global FontSize, IAGridType
14891  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14892  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
14893  global SMPfft # number of FFT samples
14894  global TRACEaverage # Number of traces for averageing
14895  global FreqTraceMode # 1 normal 2 max 3 average
14896  global Vdiv # Number of vertical divisions
14897  global ImpedanceMagnitude # in ohms
14898  global ImpedanceAngle # in degrees
14899  global ImpedanceRseries, ImpedanceXseries, Cseries # in ohms / uF
14900  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
14901  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesC
14902 
14903  # Delete all items on the screen
14904  IAca.delete(ALL) # remove all items
14905  SmoothBool = SmoothCurvesBP.get()
14906  Cparallel = 0.0
14907  Rparallel = 0.0
14908  Lparallel = 0.0
14909  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
14910  xright = 10 + GRWIA/2 + ( Vdiv.get() * Radius ) # 5
14911  OhmsperPixel = float(ResScale.get())/Radius
14912  TRadius = Radius * Vdiv.get() # 5
14913  xcenter = GRWIA/2
14914  ycenter = GRHIA/2
14915  if IAGridType.get() == 0:
14916  # Draw circular grid lines
14917  i = 1
14918  xcenter = GRWIA/2
14919  ycenter = GRHIA/2
14920  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
14921  OhmsperPixel = float(ResScale.get())/Radius
14922  TRadius = Radius * Vdiv.get() # 5
14923  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
14924  while (i <= Vdiv.get()):
14925  x0 = xcenter - ( i * Radius )
14926  x1 = xcenter + ( i * Radius )
14927  y0 = ycenter - ( i * Radius )
14928  y1 = ycenter + ( i * Radius )
14929  axisvalue = float(ResScale.get()) * i
14930  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
14931  axisvalue = axisvalue / 1000
14932  ResTxt = '{0:.1f}'.format(axisvalue)
14933  axis_label = str(ResTxt) + "K"
14934  elif axisvalue >= 100.0 or axisvalue <= -100.0:
14935  ResTxt = '{0:.1f}'.format(axisvalue)
14936  axis_label = str(ResTxt)
14937  elif axisvalue >= 10.0 or axisvalue <= -10.0:
14938  ResTxt = '{0:.2f}'.format(axisvalue)
14939  axis_label = str(ResTxt)
14940  else:
14941  ResTxt = '{0:.3f}'.format(axisvalue)
14942  axis_label = str(ResTxt)
14943  IAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
14944  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
14945  IAca.create_text(xright, y0, text=axis_label, fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14946  #
14947  i = i + 1
14948  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
14949  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
14950  RAngle = math.radians(45)
14951  y = TRadius*math.sin(RAngle)
14952  x = TRadius*math.cos(RAngle)
14953  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14954  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14955  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
14956  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14957  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
14958  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
14959  else:
14960  # Draw horizontal grid lines
14961  i = 0 - Vdiv.get()
14962  j = 0
14963  x1 = X0LIA
14964  x2 = X0LIA + TRadius * 2
14965  xcenter = x1 + (TRadius)
14966  OhmsperPixel = float(ResScale.get())/Radius
14967  while (i <= Vdiv.get()):
14968  y = Y0TIA + j * (TRadius/Vdiv.get())
14969  Dline = [x1,y,x2,y]
14970  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
14971  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14972  else:
14973  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14974  axisvalue = float(ResScale.get()) * -i
14975  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
14976  axisvalue = axisvalue / 1000
14977  ResTxt = '{0:.1f}'.format(axisvalue)
14978  axis_label = str(ResTxt) + "K"
14979  else:
14980  ResTxt = '{0:.0f}'.format(axisvalue)
14981  axis_label = str(ResTxt)
14982  IAca.create_text(x1-3, y, text=axis_label, fill=COLORtrace6, anchor="e", font=("arial", FontSize ))
14983  i = i + 1
14984  j = j + 1
14985  # Draw vertical grid lines
14986  i = 0 - Vdiv.get()
14987  j = 0
14988  y1 = Y0TIA
14989  y2 = Y0TIA + TRadius * 2
14990  ycenter = y1 + (TRadius)
14991  # "\n".join(axis_label)
14992  while (i <= Vdiv.get()): #
14993  x = x1 + j * (TRadius/Vdiv.get())
14994  Dline = [x,y1,x,y2]
14995  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
14996  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14997  else:
14998  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14999  axisvalue = float(ResScale.get()) * i
15000  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15001  axisvalue = axisvalue / 1000
15002  ResTxt = '{0:.1f}'.format(axisvalue)
15003  axis_label = str(ResTxt) + "K"
15004  else:
15005  ResTxt = '{0:.0f}'.format(axisvalue)
15006  axis_label = str(ResTxt)
15007  IAca.create_text(x, y2+3, text=axis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
15008  i = i + 1
15009  j = j + 1
15010 # Draw traces
15011  # Add saved line if there
15012  if IASweepSaved.get() > 0:
15013  if len(TIAMRline) > 4:
15014  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15015 #
15016  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
15017  if x1 > 1500:
15018  x1 = xright
15019  elif x1 < -500:
15020  x1 = xcenter - xright
15021  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
15022  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
15023  if y1 > 1500:
15024  y1 = xright
15025  elif y1 < -500:
15026  y1 = ycenter - xright
15027  xmag = x1
15028  ymag = y1
15029  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())
15030  MagRadius = ImpedanceMagnitude / OhmsperPixel
15031  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
15032  if y1 > 1500:
15033  y1 = xright
15034  elif y1 < -500:
15035  y1 = ycenter - xright
15036  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
15037  if x1 > 1500:
15038  x1 = xright
15039  elif x1 < -500:
15040  x1 = xcenter - xright
15041  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
15042 #
15043  TIAMline = []
15044  if len(NSweepSeriesMag) > 2:
15045  index = 0
15046  while index < len(NSweepSeriesMag):
15047  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
15048  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
15049  if y1 > 1500:
15050  y1 = xright
15051  elif y1 < -500:
15052  y1 = ycenter - xright
15053  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
15054  if x1 > 1500:
15055  x1 = xright
15056  elif x1 < -500:
15057  x1 = xcenter - xright
15058  TIAMline.append(x1)
15059  TIAMline.append(y1)
15060  index = index + 1
15061  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15062 # display warning if input out of range
15063  if OverRangeFlagA == 1:
15064  x = X0LIA+GRWIA+10
15065  y = Y0TIA+GRHIA-40
15066  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15067  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15068  if OverRangeFlagB == 1:
15069  x = X0LIA+GRWIA+10
15070  y = Y0TIA+GRHIA-10
15071  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15072  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15073  # General information on top of the grid
15074 
15075  txt = " Sample rate: " + str(SAMPLErate)
15076  txt = txt + " FFT samples: " + str(SMPfft)
15077 
15078  txt = txt + " " + FFTwindowname
15079  if NetworkScreenStatus.get() > 0:
15080  txt = txt + " Sweep ON"
15081  else:
15082  txt = txt + " Sweep OFF"
15083  x = X0LIA
15084  y = 12
15085  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15086  #
15087  x = X0LIA + GRWIA + 4
15088  y = 24
15089  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
15090  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15091  y = y + 24
15092  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
15093  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15094  y = y + 24
15095  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
15096  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15097  y = y + 24
15098  txt = "Impedance Magnitude"
15099  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15100  y = y + 24
15101  if ImpedanceMagnitude >= 1000.0 or ImpedanceMagnitude <= -1000.0:
15102  ImpedanceMagnitude = ImpedanceMagnitude / 1000
15103  txt = '{0:.2f}'.format(ImpedanceMagnitude)
15104  txt = str(txt) + "K"
15105  elif ImpedanceMagnitude >= 100.0 or ImpedanceMagnitude <= -100.0:
15106  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
15107  elif ImpedanceMagnitude >= 10.0 or ImpedanceMagnitude <= -10.0:
15108  txt = ' {0:.2f} '.format(ImpedanceMagnitude)
15109  else:
15110  txt = ' {0:.3f} '.format(ImpedanceMagnitude)
15111  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15112  y = y + 24
15113  txt = "Impedance Angle"
15114  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15115  y = y + 24
15116  txt = ' {0:.1f} '.format(ImpedanceAngle)
15117  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15118  y = y + 24
15119  txt = "Impedance R series"
15120  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15121  y = y + 24
15122  if ImpedanceRseries >= 1000.0 or ImpedanceRseries <= -1000.0:
15123  ImpedanceRseries = ImpedanceRseries / 1000
15124  txt = '{0:.2f}'.format(ImpedanceRseries)
15125  txt = str(txt) + "K"
15126  elif ImpedanceRseries >= 100.0 or ImpedanceRseries <= -100.0:
15127  txt = ' {0:.1f} '.format(ImpedanceRseries)
15128  elif ImpedanceRseries >= 10.0 or ImpedanceRseries <= -10.0:
15129  txt = ' {0:.2f} '.format(ImpedanceRseries)
15130  else:
15131  txt = ' {0:.3f} '.format(ImpedanceRseries)
15132  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15133  y = y + 24
15134  txt = "Impedance X series"
15135  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15136  y = y + 24
15137  if ImpedanceXseries >= 1000.0 or ImpedanceXseries <= -1000.0:
15138  ImpedanceXseries = ImpedanceXseries / 1000
15139  txt = '{0:.2f}'.format(ImpedanceXseries)
15140  txt = str(txt) + "K"
15141  if ImpedanceXseries >= 100.0 or ImpedanceXseries <= -100.0:
15142  txt = ' {0:.1f} '.format(ImpedanceXseries)
15143  elif ImpedanceXseries >= 10.0 or ImpedanceXseries <= -10.0:
15144  txt = ' {0:.2f} '.format(ImpedanceXseries)
15145  else:
15146  txt = ' {0:.3f} '.format(ImpedanceXseries)
15147  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15148 #
15149  Cseries = 0.0
15150  Cparallel = 0.0
15151  Lseries = 0.0
15152  Lparallel = 0.0
15153  Rparallel = 0.0
15154  if ImpedanceXseries < 0: # calculate series capacitance
15155  y = y + 24
15156  try:
15157  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
15158  except:
15159  Cseries = 0
15160  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
15161  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
15162  Cparallel = Cparallel * 1E6 # convert to micro Farads
15163  Rparallel = ImpedanceRseries * (1+Qseries**2)
15164  Cseries = Cseries * 1E6 # convert to micro Farads
15165  if DisplaySeries.get() == 0:
15166  txt = "Series Capacitance"
15167  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15168  y = y + 20
15169  if Cseries < 1:
15170  Ctext = Cseries * 1E3
15171  if Ctext < 1:
15172  Ctext = Ctext * 1E3
15173  CtextDis = Ctext + float(CapZeroEntry.get())
15174  txt = ' {0:.1f} '.format(CtextDis) + "pF"
15175  else:
15176  txt = ' {0:.3f} '.format(Ctext) + "nF"
15177  else:
15178  txt = ' {0:.3f} '.format(Cseries) + "uF"
15179  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15180  else:
15181  txt = "Parallel"
15182  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15183  y = y + 20
15184  if Cparallel < 1:
15185  Ctext = Cparallel * 1E3
15186  if Ctext < 1:
15187  Ctext = Ctext * 1E3
15188  txt = "Capacitance " + ' {0:.1f} '.format(Ctext) + "pF"
15189  else:
15190  txt = "Capacitance " + ' {0:.3f} '.format(Ctext) + "nF"
15191  else:
15192  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
15193  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15194  y = y + 20
15195  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15196  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15197  y = y + 20
15198  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
15199  txt = 'D = {0:.2f} '.format(dissp) + " %"
15200  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15201 
15202  elif ImpedanceXseries > 0: # calculate series inductance
15203  y = y + 24
15204  try:
15205  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
15206  except:
15207  Lseries = 0
15208  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
15209  if Qseries == 0.0: # Check if divide by zero
15210  Qseries = 0.00001
15211  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
15212  Lparallel = Lparallel * 1E3 # convert to millihenry
15213  Rparallel = ImpedanceRseries * (1+Qseries**2)
15214  Lseries = Lseries * 1E3 # in millihenry
15215  if DisplaySeries.get() == 0:
15216  txt = "Series Inductance"
15217  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15218  y = y + 22
15219  if Lseries < 1:
15220  Ltext = Lseries * 1E3
15221  txt = ' {0:.2f} '.format(Ltext) + "uH"
15222  else:
15223  txt = ' {0:.2f} '.format(Lseries) + "mH"
15224  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15225  else:
15226  txt = "Parallel"
15227  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15228  y = y + 20
15229  if Lparallel < 1:
15230  Ltext = Lparallel * 1E3
15231  txt = "Inductance " + ' {0:.2f} '.format(Ltext) + "uH"
15232  else:
15233  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
15234  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15235  y = y + 20
15236  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15237  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15238  y = y + 20
15239  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
15240  txt = 'Q = {0:.2f} '.format(qf)
15241  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15242  #
15243  if LoopNum.get() > 1:
15244  if NetworkScreenStatus.get() > 0:
15245  NSweepSeriesR.append(ImpedanceRseries)
15246  NSweepSeriesX.append(ImpedanceXseries)
15247  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
15248  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
15249  NSweepParallelR.append(Rparallel)
15250  NSweepParallelC.append(Cparallel) # in uF
15251  NSweepParallelL.append(Lparallel) # in mH
15252  NSweepSeriesC.append(Cseries) # in uF
15253  NSweepSeriesL.append(Lseries) # in mH
15254  # Start and stop frequency and trace mode
15255  if Two_X_Sample.get() == 0:
15256  txt = "0.0 to 45000 Hz"
15257  else:
15258  txt = "0.0 to 90000 Hz"
15259  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15260 
15261  x = X0LIA
15262  y = Y0TIA+GRHIA-13
15263  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15264  txt = " "
15265  if FreqTraceMode.get() == 1:
15266  txt ="Normal mode "
15267 
15268  if FreqTraceMode.get() == 2:
15269  txt = "Peak hold mode "
15270 
15271  if FreqTraceMode.get() == 3:
15272  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
15273 
15274  if ZEROstuffing.get() > 0:
15275  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
15276  # Runstatus and level information
15277  if (RUNstatus.get() == 0):
15278  txt = txt + " Stopped "
15279  else:
15280  txt = txt + " Running "
15281  y = Y0TIA+GRHIA
15282  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15283 #
15284 def IACaresize(event):
15285  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
15286 
15287  CANVASwidthIA = event.width - 4
15288  CANVASheightIA = event.height - 4
15289  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
15290  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
15291  UpdateIAAll()
15292 #
15293 # ================ Make IA Window ==========================
15295  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
15296  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode, AWG_2X
15297  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
15298  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev, CapZeroEntry
15299  global NetworkScreenStatus, IASweepSaved, IAGridType
15300  global FrameRefief, BorderSize
15301 
15302  if IAScreenStatus.get() == 0:
15303  IAScreenStatus.set(1)
15304  IADisp.set(1)
15305  IACheckBox()
15306  CutDC.set(1) # set to remove DC
15307  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
15308  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
15309  AWGAMode.set(0) # Set AWG A to SVMI
15310  AWGAShape.set(18) # Set Shape to Bode Sine
15311  ReMakeAWGwaves()
15312  if AWG_2X.get == 1:
15313  AWGBMode.set(0) # Set AWG B to SVMI
15314  else:
15315  AWGBMode.set(2) # Set AWG B to Hi-Z
15316  BAWGAModeLabel()
15317  BAWGBModeLabel()
15318  AWGSync.set(1) # Set AWGs to run sync
15319  iawindow = Toplevel()
15320  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
15321  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
15322  frame2iar = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
15323  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
15324 
15325  frame2ia = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
15326  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
15327 
15328  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
15329  IAca.bind("<Configure>", IACaresize)
15330  IAca.bind("<Return>", DoNothing)
15331  IAca.bind("<space>", onCanvasSpaceBar)
15332  IAca.pack(side=TOP, expand=YES, fill=BOTH)
15333 
15334  # menu buttons
15335  # right side drop down menu buttons
15336  dropmenu = Frame( frame2iar )
15337  dropmenu.pack(side=TOP)
15338  # File menu
15339  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15340  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
15341  IAFilemenu["menu"] = IAFilemenu.menu
15342  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
15343  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
15344  IAFilemenu.menu.add_command(label="Run Script", command=RunScript)
15345  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
15346  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
15347  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
15348  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
15349  IAFilemenu.menu.add_command(label="Help", command=BHelp)
15350  IAFilemenu.pack(side=LEFT, anchor=W)
15351  #
15352  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15353  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
15354  IAOptionmenu["menu"] = IAOptionmenu.menu
15355  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15356  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15357  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15358  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
15359  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
15360  if DeBugMode == 1:
15361  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
15362  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
15363  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
15364  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
15365  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
15366  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
15367  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
15368  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
15369  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
15370  IAOptionmenu.pack(side=LEFT, anchor=W)
15371  #
15372  rsemenu = Frame( frame2iar )
15373  rsemenu.pack(side=TOP)
15374  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
15375  rseb2.pack(side=RIGHT)
15376  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
15377  rseb3.pack(side=RIGHT)
15378  #
15379  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
15380  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
15381  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
15382  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15383  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15384  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15385  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15386  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15387  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15388  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15389  IAFFTwindmenu.pack(side=TOP)
15390  #
15391  smpmenu = Frame( frame2iar )
15392  smpmenu.pack(side=TOP)
15393  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15394  smpb1.pack(side=LEFT)
15395  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15396  smpb2.pack(side=LEFT)
15397  # Temp set source resistance to 1000
15398  rsystem = Frame( frame2iar )
15399  rsystem.pack(side=TOP)
15400  rsystemlab = Label(rsystem, text="Ext Res")
15401  rsystemlab.pack(side=LEFT, anchor=W)
15402  RsystemEntry = Entry(rsystem, width=7, cursor='double_arrow')
15403  RsystemEntry.bind('<Return>', onTextKey)
15404  RsystemEntry.bind('<MouseWheel>', onTextScroll)
15405  RsystemEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15406  RsystemEntry.bind("<Button-5>", onTextScroll)
15407  RsystemEntry.bind('<Key>', onTextKey)
15408  RsystemEntry.pack(side=LEFT, anchor=W)
15409  RsystemEntry.delete(0,"end")
15410  RsystemEntry.insert(4,1000)
15411  # Res Scale Spinbox
15412  ressb = Frame( frame2iar )
15413  ressb.pack(side=TOP)
15414  reslab = Label(ressb, text="Ohms/div ")
15415  reslab.pack(side=LEFT)
15416  ResScale = Spinbox(ressb, width=7, cursor='double_arrow', values=ResScalediv)
15417  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
15418  ResScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
15419  ResScale.bind("<Button-5>", onSpinBoxScroll)
15420  ResScale.pack(side=LEFT)
15421  ResScale.delete(0,"end")
15422  ResScale.insert(0,500)
15423  #
15424  GainCor = Frame( frame2iar )
15425  GainCor.pack(side=TOP)
15426  GainCorlab = Label(GainCor, text="Gain Cor dB")
15427  GainCorlab.pack(side=LEFT, anchor=W)
15428  GainCorEntry = Entry(GainCor, width=7, cursor='double_arrow')
15429  GainCorEntry.bind('<Return>', onTextKey)
15430  GainCorEntry.bind('<MouseWheel>', onTextScroll)
15431  GainCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15432  GainCorEntry.bind("<Button-5>", onTextScroll)
15433  GainCorEntry.bind('<Key>', onTextKey)
15434  GainCorEntry.pack(side=LEFT, anchor=W)
15435  GainCorEntry.delete(0,"end")
15436  GainCorEntry.insert(4,0.0)
15437  #
15438  PhaseCor = Frame( frame2iar )
15439  PhaseCor.pack(side=TOP)
15440  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
15441  PhaseCorlab.pack(side=LEFT, anchor=W)
15442  PhaseCorEntry = Entry(PhaseCor, width=7, cursor='double_arrow')
15443  PhaseCorEntry.bind('<Return>', onTextKey)
15444  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
15445  PhaseCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15446  PhaseCorEntry.bind("<Button-5>", onTextScroll)
15447  PhaseCorEntry.bind('<Key>', onTextKey)
15448  PhaseCorEntry.pack(side=LEFT, anchor=W)
15449  PhaseCorEntry.delete(0,"end")
15450  PhaseCorEntry.insert(4,0.0)
15451  #
15452  capofflab = Label(frame2iar, text="Capacitance Offset")
15453  capofflab.pack(side=TOP)
15454  CapZero = Frame( frame2iar )
15455  CapZero.pack(side=TOP)
15456  CapZerobutton = Button(CapZero, text="Zero", style="W4.TButton", command=IACapZero)
15457  CapZerobutton.pack(side=LEFT, anchor=W)
15458  CapResetbutton = Button(CapZero, text="Reset", style="W5.TButton", command=IACapReset)
15459  CapResetbutton.pack(side=LEFT, anchor=W)
15460  CapZeroEntry = Entry(CapZero, width=6, cursor='double_arrow')
15461  CapZeroEntry.bind('<Return>', onTextKey)
15462  CapZeroEntry.bind('<MouseWheel>', onTextScroll)
15463  CapZeroEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15464  CapZeroEntry.bind("<Button-5>", onTextScroll)
15465  CapZeroEntry.bind('<Key>', onTextKey)
15466  CapZeroEntry.pack(side=LEFT, anchor=W)
15467  CapZeroEntry.delete(0,"end")
15468  CapZeroEntry.insert(4,0.0)
15469  #
15470  srclab = Label(frame2iar, text="Source")
15471  srclab.pack(side=TOP)
15472  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
15473  extsrc1.pack(side=TOP)
15474  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
15475  extsrc2.pack(side=TOP)
15476  #
15477  gridmenu = Frame( frame2iar )
15478  gridmenu.pack(side=TOP)
15479  iagrid1= Radiobutton(frame2iar, text="Polar Grid", variable=IAGridType, value=0) #, command=IAGridSet)
15480  iagrid1.pack(side=TOP)
15481  iagrid2 = Radiobutton(frame2iar, text="Rect Grid", variable=IAGridType, value=1) #, command=IAGridSet)
15482  iagrid2.pack(side=TOP)
15483  #
15484  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
15485  dismiss1button.pack(side=TOP)
15486  # add ADI logo
15487  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
15488  ADI1.pack(side=TOP)
15489 #
15491  global iawindow, IAScreenStatus, IAca, IADisp
15492 
15493  IAScreenStatus.set(0)
15494  IADisp.set(0)
15495  IACheckBox()
15496  iawindow.destroy()
15497 #
15499  global TIAMline, TIAMRline, IASweepSaved
15500 
15501  if IASweepSaved.get() > 0:
15502  TIAMRline = TIAMline
15503 #
15505  global Cseries, CapZeroEntry
15506 
15507  Ctext = ' {0:.1f} '.format(-Cseries * 1E6)
15508  CapZeroEntry.delete(0,"end")
15509  CapZeroEntry.insert(6,Ctext)
15510 #
15512  global CapZeroEntry
15513 
15514  CapZeroEntry.delete(0,"end")
15515  CapZeroEntry.insert(4,0.0)
15516 #
15518  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
15519  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
15520  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
15521  global NetworkScreenStatus, NqPSweepSaved
15522  global FrameRefief, BorderSize
15523 
15524  if NqPScreenStatus.get() == 0:
15525  NqPScreenStatus.set(1)
15526  NqPDisp.set(1)
15527  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
15528  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
15529  nqpwindow = Toplevel()
15530  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
15531  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
15532 
15533  frame2nqp = Frame(nqpwindow, borderwidth=BorderSize, relief=FrameRefief)
15534  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
15535 
15536  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
15537  NqPca.bind("<Configure>", NqPCaresize)
15538  NqPca.bind("<Return>", DoNothing)
15539  NqPca.bind("<space>", onCanvasSpaceBar)
15540  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
15541 #
15543  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
15544 
15545  NqPScreenStatus.set(0)
15546  NqPDisp.set(0)
15547  nqpwindow.destroy()
15548 #
15549 def NqPCaresize(event):
15550  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
15551 
15552  CANVASwidthNqP = event.width - 4
15553  CANVASheightNqP = event.height - 4
15554  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
15555  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
15556  UpdateNqPAll()
15557 
15560  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
15561  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
15562  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
15563  global Vdiv, FBins, FStep
15564  global FontSize
15565 
15566  # Delete all items on the canvas
15567  NqPca.delete(ALL) # remove all items
15568  SmoothBool = SmoothCurvesBP.get()
15569  # Draw circular grid lines
15570  i = 1
15571  xcenter = GRWNqP/2
15572  ycenter = GRHNqP/2
15573  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
15574  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
15575  TRadius = Radius * Vdiv.get() # 5
15576  x1 = X0LNqP
15577  x2 = X0LNqP + GRWNqP
15578  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
15579  while (i <= Vdiv.get()):
15580  x0 = xcenter - ( i * Radius )
15581  x1 = xcenter + ( i * Radius )
15582  y0 = ycenter - ( i * Radius )
15583  y1 = ycenter + ( i * Radius )
15584  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15585  NqPca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
15586  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
15587  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15588  #
15589  i = i + 1
15590  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
15591  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
15592  RAngle = math.radians(45)
15593  y = TRadius*math.sin(RAngle)
15594  x = TRadius*math.cos(RAngle)
15595  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15596  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15597  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
15598  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15599  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
15600  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
15601  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
15602 # Draw traces
15603  NqPline = []
15604  if len(FSweepAdB) > 4:
15605  for index in range(len(FSweepAdB)): # while n < len(FStep):
15606  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
15607  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
15608  else:
15609  F = FBins[int(FStep[0])]
15610  # Mag value
15611  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
15612  dbB = 10 * math.log10(float(FSweepBdB[index]))
15613  if ShowMathBP.get() == 1:
15614  MdB = dbA - dbB
15615  elif ShowMathBP.get() == 2:
15616  MdB = dbB - dbA
15617  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
15618  # Phase Value
15619  RelPhase = FSweepBPh[index] - FSweepAPh[index]
15620  if RelPhase > 180:
15621  RelPhase = RelPhase - 360
15622  elif RelPhase < -180:
15623  RelPhase = RelPhase + 360
15624  if Two_X_Sample.get() == 0:
15625  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15626  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
15627  else:
15628  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
15629  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
15630  if y1 > 1500:
15631  y1 = xright
15632  elif y1 < -500:
15633  y1 = ycenter - xright
15634  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
15635  if x1 > 1500:
15636  x1 = xright
15637  elif x1 < -500:
15638  x1 = xcenter - xright
15639  NqPline.append(x1)
15640  NqPline.append(y1)
15641  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15642 #
15644  global NiCScreenStatus, NiCDisp
15645  global nicwindow, NiCca, logo, SWRev
15646  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
15647  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
15648  global NetworkScreenStatus, NiCSweepSaved
15649  global FrameRefief, BorderSize
15650 
15651  if NiCScreenStatus.get() == 0:
15652  NiCScreenStatus.set(1)
15653  NiCDisp.set(1)
15654  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
15655  CANVASheightNic = GRHNiC + 60 # The canvas height
15656  nicwindow = Toplevel()
15657  nicwindow.title("Nichols Plot " + SWRev + RevDate)
15658  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
15659 
15660  frame2nic = Frame(nicwindow, borderwidth=BorderSize, relief=FrameRefief)
15661  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
15662 
15663  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
15664  NiCca.bind("<Configure>", NiCCaresize)
15665  NiCca.bind("<Return>", DoNothing)
15666  NiCca.bind("<space>", onCanvasSpaceBar)
15667  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
15668 #
15670  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
15671 
15672  NiCScreenStatus.set(0)
15673  NiCDisp.set(0)
15674  nicwindow.destroy()
15675 #
15676 def NiCCaresize(event):
15677  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
15678 
15679  CANVASwidthNic = event.width - 4
15680  CANVASheightNic = event.height - 4
15681  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
15682  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
15683  UpdateNiCAll()
15684 
15687  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
15688  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
15689  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
15690  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
15691  global FontSize
15692 
15693  Ymin = Y0TNiC # Minimum position of XY grid (top)
15694  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
15695  Xmin = X0LNiC # Minimum position of XY grid (left)
15696  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
15697  try:
15698  Phasecenter = int(PhCenBodeEntry.get())
15699  RelPhaseCenter.set(Phasecenter)
15700  except:
15701  PhCenBodeEntry.delete(0,"end")
15702  PhCenBodeEntry.insert(0,0)
15703  RelPhaseCenter.set(0)
15704  Phasecenter = 0
15705  # Delete all items on the screen
15706  MarkerNum = 0
15707  SmoothBool = SmoothCurvesBP.get()
15708  NiCca.delete(ALL) # remove all items
15709  # Draw horizontal grid lines Rel Gain Magnitude
15710  i = 0
15711  x1 = X0LNiC
15712  x2 = X0TNiC = X0LNiC + GRWNiC
15713  mg_siz = GRWNiC/10.0
15714  mg_inc = mg_siz/5.0
15715  DegPerDiv = 360 / 10
15716  while (i < Vdiv.get()+1):
15717  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15718  y = Y0TNiC + i * GRHNiC/Vdiv.get()
15719  Dline = [x1,y,x2,y]
15720  if dBaxis_value == 0:
15721  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
15722  k = 0
15723  while (k < 10):
15724  l = 1
15725  while (l < 5): # add tick marks
15726  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
15727  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15728  l = l + 1
15729  k = k + 1
15730  else:
15731  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15732  dBaxis_label = str(dBaxis_value)
15733  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15734 
15735  i = i + 1
15736  # Draw vertical grid lines (phase -180 to 180 10 div)
15737  i = 0
15738  y1 = Y0TNiC
15739  y2 = Y0TNiC + GRHNiC
15740  mg_siz = GRHNiC/10.0
15741  mg_inc = mg_siz/5.0
15742  #
15743  while (i < 11):
15744  x = X0LNiC + i * GRWNiC/10.0
15745  Dline = [x,y1,x,y2]
15746  axis_value = Phasecenter - 180 + (i * DegPerDiv)
15747  axis_label = str(axis_value)
15748  if ( axis_value == 0):
15749  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
15750  k = 0
15751  while (k < 10):
15752  l = 1
15753  while (l < 5): # add tick marks
15754  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
15755  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15756  l = l + 1
15757  k = k + 1
15758  else:
15759  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15760  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
15761  i = i + 1
15762  # Draw traces
15763  # Vertical conversion factors (level dBs) and border limits
15764  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15765  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15766  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
15767  Xp = float(X0LNiC) + Xphconv * 180.0
15768  x1 = X0LNiC + 14
15769  # Horizontal conversion factors (phase deg) and border limits
15770  NiCline = []
15771  if len(FSweepAdB) > 4:
15772  index = 0
15773  for index in range(len(FSweepAdB)): # while n < len(FStep):
15774  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
15775  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
15776  else:
15777  F = FBins[int(FStep[0])]
15778  # Mag value
15779  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
15780  dbB = 10 * math.log10(float(FSweepBdB[index]))
15781  if ShowMathBP.get() == 1:
15782  MdB = dbA - dbB
15783  elif ShowMathBP.get() == 2:
15784  MdB = dbB - dbA
15785  yb = Yc - Yconv * MdB
15786  if (yb < Ymin):
15787  yb = Ymin
15788  if (yb > Ymax):
15789  yb = Ymax
15790  # Phase Value
15791  RelPhase = FSweepBPh[index] - FSweepAPh[index]
15792  RelPhase = RelPhase - Phasecenter
15793  if RelPhase > 180:
15794  RelPhase = RelPhase - 360
15795  elif RelPhase < -180:
15796  RelPhase = RelPhase + 360
15797  if Two_X_Sample.get() == 0:
15798  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15799  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
15800  else:
15801  RelPhase = RelPhase # - PhaseOffset2x
15802  xa = Xp + Xphconv * RelPhase
15803  if (xa < Xmin):
15804  xa = Ymin
15805  if (xa > Xmax):
15806  xa = Xmax
15807  NiCline.append(int(xa + 0.5))
15808  NiCline.append(int(yb + 0.5))
15809  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15810 #
15811 def UpdateNqPAll(): # Update Data, trace and screen
15812  global FFTBuffA, FFTBuffB
15813  global SMPfft
15814 
15815  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15816  return
15817  #MakeNqPTrace() # Update the traces
15818  UpdateNqPScreen() # Update the screen
15819 
15820 def UpdateNqPTrace(): # Update trace and screen
15821 
15822  #MakeNqPTrace() # Update traces
15823  UpdateNqPScreen() # Update the screen
15824 
15825 def UpdateNqPScreen(): # Update screen with trace and text
15826 
15827  MakeNqPScreen() # Update the screen
15828  root.update() # Activate updated screens
15829 #
15830 def UpdateNiCAll(): # Update Data, trace and screen
15831  global FFTBuffA, FFTBuffB
15832  global SMPfft
15833 
15834  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15835  return
15836  #MakeNiCTrace() # Update the traces
15837  UpdateNiCScreen() # Update the screen
15838 
15839 def UpdateNiCTrace(): # Update trace and screen
15840 
15841  #MakeNiCTrace() # Update traces
15842  UpdateNiCScreen() # Update the screen
15843 
15844 def UpdateNiCScreen(): # Update screen with trace and text
15845 
15846  MakeNiCScreen() # Update the screen
15847  root.update() # Activate updated screens
15848 #
15849 #
15850 def VAtoggle():
15851  global vat_btn
15852 
15853  if vat_btn.config('text')[-1] == 'ON':
15854  vat_btn.config(text='OFF', style="Stop.TButton")
15855  else:
15856  vat_btn.config(text='ON', style="Run.TButton")
15857 #
15859  global vabt_btn
15860 
15861  if vabt_btn.config('text')[-1] == 'ON':
15862  vabt_btn.config(text='OFF', style="Stop.TButton")
15863  else:
15864  vabt_btn.config(text='ON', style="Run.TButton")
15865 #
15866 def VBtoggle():
15867  global vbt_btn
15868 
15869  if vbt_btn.config('text')[-1] == 'ON':
15870  vbt_btn.config(text='OFF', style="Stop.TButton")
15871  else:
15872  vbt_btn.config(text='ON', style="Run.TButton")
15873 #
15874 def IAtoggle():
15875  global iat_btn
15876 
15877  if iat_btn.config('text')[-1] == 'ON':
15878  iat_btn.config(text='OFF', style="Stop.TButton")
15879  else:
15880  iat_btn.config(text='ON', style="Run.TButton")
15881 #
15882 def IBtoggle():
15883  global ibt_btn
15884 
15885  if ibt_btn.config('text')[-1] == 'ON':
15886  ibt_btn.config(text='OFF', style="Stop.TButton")
15887  else:
15888  ibt_btn.config(text='ON', style="Run.TButton")
15889 #
15890 # ================ Make Phase Ana Window ==========================
15892  global phawindow, PhAca, logo, PhAScreenStatus, PhADisp, AWGSync
15893  global COLORcanvas, CANVASwidthPhA, CANVASheightPhA, RevDate, AWGAMode, AWGAShape, AWGBMode
15894  global FFTwindow, CutDC, ColorMode, RefPhase, CHvpdiv, CHipdiv
15895  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, DeBugMode, SWRev, PhAPlotMode
15896  global VScale, IScale, RefphEntry, MuxScreenStatus, AppendPhAData
15897  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
15898  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
15899  global FrameRefief, BorderSize
15900 
15901  if PhAScreenStatus.get() == 0:
15902  PhAScreenStatus.set(1)
15903  PhADisp.set(1)
15904  PhACheckBox()
15905  CutDC.set(1) # set to remove DC
15906  CANVASwidthPhA = 170 + GRWPhA + 2 * X0LPhA # The canvas width
15907  CANVASheightPhA = GRHPhA + Y0TPhA + 10 # The canvas height
15908  phawindow = Toplevel()
15909  phawindow.title("Phase Analyzer " + SWRev + RevDate)
15910  phawindow.protocol("WM_DELETE_WINDOW", DestroyPhAScreen)
15911  frame2phar = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
15912  frame2phar.pack(side=RIGHT, expand=NO, fill=BOTH)
15913 
15914  frame2pha = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
15915  frame2pha.pack(side=TOP, expand=YES, fill=BOTH)
15916 
15917  PhAca = Canvas(frame2pha, width=CANVASwidthPhA, height=CANVASheightPhA, background=COLORcanvas, cursor='cross')
15918  PhAca.bind("<Configure>", PhACaresize)
15919  PhAca.bind("<Return>", DoNothing)
15920  PhAca.bind("<space>", onCanvasSpaceBar)
15921  PhAca.pack(side=TOP, expand=YES, fill=BOTH)
15922 
15923  if MuxScreenStatus.get() == 0:
15924  RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
15925  else:
15926  RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
15927  # menu buttons
15928  # right side drop down menu buttons
15929  dropmenu = Frame( frame2phar )
15930  dropmenu.pack(side=TOP)
15931  # File menu
15932  PhAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15933  PhAFilemenu.menu = Menu(PhAFilemenu, tearoff = 0 )
15934  PhAFilemenu["menu"] = PhAFilemenu.menu
15935  PhAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
15936  PhAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
15937  PhAFilemenu.menu.add_command(label="Run Script", command=RunScript)
15938  PhAFilemenu.menu.add_command(label="Save Data", command=BSavePhAData)
15939  PhAFilemenu.menu.add_checkbutton(label=' - Append', variable=AppendPhAData)
15940  PhAFilemenu.menu.add_command(label="Plot From File", command=PlotPhAFromFile)
15941  PhAFilemenu.menu.add_radiobutton(label=' - Vectors', variable=PhAPlotMode, value=0)
15942  PhAFilemenu.menu.add_radiobutton(label=' - Outline', variable=PhAPlotMode, value=1)
15943  PhAFilemenu.menu.add_command(label="Help", command=BHelp)
15944  PhAFilemenu.pack(side=LEFT, anchor=W)
15945  #
15946  PhAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15947  PhAOptionmenu.menu = Menu(PhAOptionmenu, tearoff = 0 )
15948  PhAOptionmenu["menu"] = PhAOptionmenu.menu
15949  PhAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15950  PhAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15951  PhAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15952 
15953  PhAOptionmenu.menu.add_command(label="-Background-", command=donothing)
15954  PhAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
15955  PhAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
15956  PhAOptionmenu.pack(side=LEFT, anchor=W)
15957  #
15958  rsphmenu = Frame( frame2phar )
15959  rsphmenu.pack(side=TOP)
15960  rsphb2 = Button(rsphmenu, text="Stop", style="Stop.TButton", command=BStop)
15961  rsphb2.pack(side=RIGHT)
15962  rsphb3 = Button(rsphmenu, text="Run", style="Run.TButton", command=BStart)
15963  rsphb3.pack(side=RIGHT)
15964  #
15965  PhAFFTwindmenu = Menubutton(frame2phar, text="FFTwindow", style="W11.TButton")
15966  PhAFFTwindmenu.menu = Menu(PhAFFTwindmenu, tearoff = 0 )
15967  PhAFFTwindmenu["menu"] = PhAFFTwindmenu.menu
15968  PhAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15969  PhAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15970  PhAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15971  PhAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15972  PhAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15973  PhAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15974  PhAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15975  PhAFFTwindmenu.pack(side=TOP)
15976  #
15977  FFTwindow.set(6) # default to Flat top window (6)
15978  #
15979  smphmenu = Frame( frame2phar )
15980  smphmenu.pack(side=TOP)
15981  smphb1 = Button(smphmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15982  smphb1.pack(side=LEFT)
15983  smphb2 = Button(smphmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15984  smphb2.pack(side=LEFT)
15985  #
15986  refph = Frame( frame2phar )
15987  refph.pack(side=TOP)
15988  refphlab = Label(refph, text="Ref Phase")
15989  refphlab.pack(side=LEFT, anchor=W)
15990  RefphEntry = Spinbox(refph, width=5, cursor='double_arrow', values=RefPhase)
15991  RefphEntry.bind('<MouseWheel>', onSpinBoxScroll)
15992  RefphEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
15993  RefphEntry.bind("<Button-5>", onSpinBoxScroll)
15994  RefphEntry.pack(side=LEFT, anchor=W)
15995  RefphEntry.delete(0,"end")
15996  RefphEntry.insert(0,"CA-V")
15997  vatb = Frame( frame2phar )
15998  vatb.pack(side=TOP)
15999  vatblab = Label(vatb, text="CA-V ")
16000  vatblab.pack(side=LEFT)
16001  vat_btn = Button(vatb, text="OFF", style="Stop.TButton", width=4, command=VAtoggle)
16002  vat_btn.pack(side=LEFT)
16003  vbtb = Frame( frame2phar )
16004  vbtb.pack(side=TOP)
16005  if MuxScreenStatus.get() == 0:
16006  #RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
16007  vbtblab = Label(vbtb, text="CB-V ")
16008  vbtblab.pack(side=LEFT)
16009  vbt_btn = Button(vbtb, text="OFF", style="Stop.TButton", width=4, command=VBtoggle)
16010  vbt_btn.pack(side=LEFT)
16011  vabtb = Frame( frame2phar )
16012  vabtb.pack(side=TOP)
16013  vabtblab = Label(vabtb, text="CA-B V ")
16014  vabtblab.pack(side=LEFT)
16015  vabt_btn = Button(vabtb, text="OFF", style="Stop.TButton", width=4, command=VABtoggle)
16016  vabt_btn.pack(side=LEFT)
16017  else:
16018  #RefphEntry.configure(state=DISABLED)
16019  #RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
16020  amuxlab = Label(frame2phar, text="Analog Mux In")
16021  amuxlab.pack(side=TOP)
16022  phbt1 = Checkbutton(frame2phar, text='CB-A ', style="Strace2.TCheckbutton", variable=ShowPB_A)
16023  phbt1.pack(side=TOP)
16024  phbt2 = Checkbutton(frame2phar, text='CB-B ', style="Strace6.TCheckbutton", variable=ShowPB_B) #, command=TraceSelectADC_Mux)
16025  phbt2.pack(side=TOP)
16026  phbt3 = Checkbutton(frame2phar, text='CB-C ', style="Strace7.TCheckbutton", variable=ShowPB_C) #, command=TraceSelectADC_Mux)
16027  phbt3.pack(side=TOP)
16028  phbt4 = Checkbutton(frame2phar, text='CB-D ', style="Strace4.TCheckbutton", variable=ShowPB_D) #, command=TraceSelectADC_Mux)
16029  phbt4.pack(side=TOP)
16030 #
16031  # Voltage Scale Spinbox
16032  vssb = Frame( frame2phar )
16033  vssb.pack(side=TOP)
16034  vslab = Label(vssb, text="Volts/div ")
16035  vslab.pack(side=LEFT)
16036  VScale = Spinbox(vssb, width=7, cursor='double_arrow', values=CHvpdiv)
16037  VScale.bind('<MouseWheel>', onSpinBoxScroll)
16038  VScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16039  VScale.bind("<Button-5>", onSpinBoxScroll)
16040  VScale.pack(side=LEFT)
16041  VScale.delete(0,"end")
16042  VScale.insert(0,0.5)
16043  #
16044  iatb = Frame( frame2phar )
16045  iatb.pack(side=TOP)
16046  iatblab = Label(iatb, text="CA-I ")
16047  iatblab.pack(side=LEFT)
16048  iat_btn = Button(iatb, text="OFF", style="Stop.TButton", width=4, command=IAtoggle)
16049  iat_btn.pack(side=LEFT)
16050  ibtb = Frame( frame2phar )
16051  ibtb.pack(side=TOP)
16052  ibtblab = Label(ibtb, text="CB-I ")
16053  ibtblab.pack(side=LEFT)
16054  ibt_btn = Button(ibtb, text="OFF", style="Stop.TButton", width=4, command=IBtoggle)
16055  ibt_btn.pack(side=LEFT)
16056  # Current Scale Spinbox
16057  issb = Frame( frame2phar )
16058  issb.pack(side=TOP)
16059  islab = Label(issb, text="mA/div ")
16060  islab.pack(side=LEFT)
16061  IScale = Spinbox(issb, width=7, cursor='double_arrow', values=CHipdiv)
16062  IScale.bind('<MouseWheel>', onSpinBoxScroll)
16063  IScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16064  IScale.bind("<Button-5>", onSpinBoxScroll)
16065  IScale.pack(side=LEFT)
16066  IScale.delete(0,"end")
16067  IScale.insert(0,10.0)
16068 
16069  dismiss1button = Button(frame2phar, text="Dismiss", style="W8.TButton", command=DestroyPhAScreen)
16070  dismiss1button.pack(side=TOP)
16071  # add ADI logo
16072  ADI1 = Label(frame2phar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16073  ADI1.pack(side=TOP)
16074 #
16075 # Destroy Phase Analizer window
16077  global phawindow, PhAScreenStatus, PhAca, PhADisp
16078 
16079  PhAScreenStatus.set(0)
16080  PhADisp.set(0)
16081  PhACheckBox()
16082  phawindow.destroy()
16083 #
16084 # Resize Phase Analizer window
16085 def PhACaresize(event):
16086  global PhAca, GRWPhA, XOLPhA, GRHPhA, Y0TPhA, CANVASwidthPhA, CANVASheightPhA, FontSize
16087 
16088  CANVASwidthPhA = event.width - 4
16089  CANVASheightPhA = event.height - 4
16090  GRWPhA = CANVASwidthPhA - (2 * X0LPhA) - int(21.25 * FontSize) # 170 new grid width
16091  GRHPhA = CANVASheightPhA - Y0TPhA - int(2.25 * FontSize) # 10 new grid height
16092  UpdatePhAAll()
16093 #
16094 def UpdatePhAAll(): # Update Data, trace and screen
16095 
16096  MakePhATrace() # Update the traces
16097  UpdatePhAScreen() # Update the screen
16098 
16099 def UpdatePhATrace(): # Update trace and screen
16100  MakePhATrace() # Update traces
16101  UpdatePhAScreen() # Update the screen
16102 
16103 def UpdatePhAScreen(): # Update screen with trace and text
16104  MakePhAScreen() # Update the screen
16105  root.update() # Activate updated screens
16106 #
16107 # Place holder
16108 def MakePhATrace(): # Update the grid and trace
16109  global VAresult, VBresult, IAresult, IBresult, VABresult, PhaseIA, PhaseIB, PhaseVA, PhaseVB, PhaseVAB
16110  global VMAresult, VMBresult, VMCresult, VMDresult, PhaseVMD, PhaseVMA, PhaseVMB, PhaseVMC
16111  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB
16112  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16113  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16114  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB
16115  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16116  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16117  global GRHPhA # Screenheight
16118  global GRWPhA # Screenwidth
16119  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
16120  global STARTsample, STOPsample, LoopNum, FSweepMode
16121  global TRACEmode, Two_X_Sample, MuxScreenStatus, MuxChan, ChopMuxMode
16122  global Vdiv # Number of vertical divisions
16123  global X0LPhA # Left top X value
16124  global Y0TPhA # Left top Y value
16125 
16126  # Set the TRACEsize variable
16127  if len(VAresult) < 32:
16128  return
16129  TRACEsize = len(VAresult) # Set the trace length
16130  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
16131  # Horizontal conversion factors (frequency Hz) and border limits
16132  STARTsample = 0 # First sample in FFTresult[] that is used
16133  STARTsample = int(math.ceil(STARTsample)) # First within screen range
16134  if Two_X_Sample.get() == 0:
16135  STOPsample = 45000 / Fsample # Last sample in FFTresult that is used
16136  else:
16137  STOPsample = 90000 / Fsample
16138  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
16139 #
16140 
16141  MAXsample = TRACEsize # Just an out of range check
16142  if STARTsample > (MAXsample - 1):
16143  STARTsample = MAXsample - 1
16144 
16145  if STOPsample > MAXsample:
16146  STOPsample = MAXsample
16147 
16148  n = STARTsample +1
16149  PeakVA = PeakVB = PeakIA = PeakIB = PeakVAB = 0.0
16150  PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = F = n * Fsample
16151  PeakphaseVA = PhaseVA[n]
16152  if MuxScreenStatus.get() == 0:
16153  PeakphaseVB = PhaseVB[n]
16154  else:
16155  PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
16156  PeakphaseIA = PhaseIA[n]
16157  PeakphaseIB = PhaseIB[n]
16158  PeakSampleVB = PeakSampleVA = PeakSampleIA = PeakSampleIB = n
16159  PeakSampleVMA = PeakSampleVMB = PeakSampleVMC = PeakSampleVMD = n
16160  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16161  PeakVMA = 0
16162  PeakphaseVMA = PhaseVMA[n]
16163  PeakSampleVMA = 0
16164  PeakfreqVMA = PeakfreqVA
16165  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16166  PeakVMB = 0
16167  PeakphaseVMB = PhaseVMB[n]
16168  PeakSampleVMB = 0
16169  PeakfreqVMB = PeakfreqVA
16170  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16171  PeakVMC = 0
16172  PeakphaseVMC = PhaseVMC[n]
16173  PeakSampleVMC = 0
16174  PeakfreqVMC = PeakfreqVA
16175  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16176  PeakVMD = 0
16177  PeakphaseVMD = PhaseVMD[n]
16178  PeakSampleVMD = 0
16179  PeakfreqVMD = PeakfreqVA
16180 
16181  while n <= STOPsample: # search for peaks
16182  F = n * Fsample
16183  try:
16184  VA = float(VAresult[n]) #
16185  except:
16186  VA = 0.0
16187  if VA > PeakVA:
16188  PeakVA = VA
16189  PeakfreqVA = F
16190  PeakphaseVA = PhaseVA[n]
16191  PeakSampleVA = n
16192 
16193  if MuxScreenStatus.get() == 0:
16194  try:
16195  VAB = float(VABresult[n]) #
16196  except:
16197  VAB = 0.0
16198  if VAB > PeakVAB:
16199  PeakVAB = VAB
16200  PeakfreqVAB = F
16201  PeakphaseVAB = PhaseVAB[n]
16202  PeakSampleVAB = n
16203 
16204  try:
16205  VB = float(VBresult[n]) #
16206  except:
16207  VB = 0.0
16208  if VB > PeakVB:
16209  PeakVB = VB
16210  PeakfreqVB = F
16211  PeakphaseVB = PhaseVB[n]
16212  PeakSampleVB = n
16213  else:
16214  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16215  try:
16216  VMA = float(VMAresult[n]) #
16217  except:
16218  VMA = 0.0
16219  if VMA > PeakVMA:
16220  PeakVMA = VMA
16221  PeakfreqVMA = F
16222  PeakphaseVMA = PhaseVMA[n]
16223  PeakSampleVMA = n
16224  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16225  try:
16226  VMB = float(VMBresult[n]) #
16227  except:
16228  VMB = 0.0
16229  if VMB > PeakVMB:
16230  PeakVMB = VMB
16231  PeakfreqVMB = F
16232  PeakphaseVMB = PhaseVMB[n]
16233  PeakSampleVMB = n
16234  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16235  try:
16236  VMC = float(VMCresult[n]) #
16237  except:
16238  VMC = 0.0
16239  if VMC > PeakVMC:
16240  PeakVMC = VMC
16241  PeakfreqVMC = F
16242  PeakphaseVMC = PhaseVMC[n]
16243  PeakSampleVMC = n
16244  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16245  try:
16246  VMD = float(VMDresult[n]) #
16247  except:
16248  VMD = 0.0
16249  if VMD > PeakVMD:
16250  PeakVMD = VMD
16251  PeakfreqVMD = F
16252  PeakphaseVMD = PhaseVMD[n]
16253  PeakSampleVMD = n
16254  try:
16255  IA = float(IAresult[n]) #
16256  except:
16257  IA = 0.0
16258  if IA > PeakIA:
16259  PeakIA = IA
16260  PeakfreqIA = F
16261  PeakphaseIA = PhaseIA[n]
16262  PeakSampleIA = n
16263 
16264  try:
16265  IB = float(IBresult[n]) #
16266  except:
16267  IB = 0.0
16268  if IB > PeakIB:
16269  PeakIB = IB
16270  PeakfreqIB = F
16271  PeakphaseIB = PhaseIB[n]
16272  PeakSampleIB = n
16273 
16274  n = n + 1
16275  # Check to see that V, Vnux and I peaks are in same frequency bin?
16276  if PeakSampleVA != PeakSampleIA:
16277  PeakphaseIA = PhaseIA[PeakSampleVA]
16278  PeakIA = IAresult[PeakSampleVA]
16279  if PeakSampleVB != PeakSampleIB and MuxScreenStatus.get() == 0:
16280  PeakphaseIB = PhaseIB[PeakSampleVB]
16281  PeakIB = IBresult[PeakSampleVB]
16282  if MuxScreenStatus.get() > 0:
16283  if PeakSampleVA != PeakSampleVMA:
16284  try:
16285  PeakphaseVMA = PhaseVMA[PeakSampleVA]
16286  PeakVMA = float(VMAresult[PeakSampleVA])
16287  except:
16288  donothing()
16289  if PeakSampleVA != PeakSampleVMB:
16290  try:
16291  PeakphaseVMB = PhaseVMB[PeakSampleVA]
16292  PeakVMB = float(VMBresult[PeakSampleVA])
16293  except:
16294  donothing()
16295  if PeakSampleVA != PeakSampleVMC:
16296  try:
16297  PeakphaseVMC = PhaseVMC[PeakSampleVA]
16298  PeakVMC = float(VMCresult[PeakSampleVA])
16299  except:
16300  donothing()
16301  if PeakSampleVA != PeakSampleVMD:
16302  try:
16303  PeakphaseVMD = PhaseVMD[PeakSampleVA]
16304  PeakVMD = float(VMDresult[PeakSampleVA])
16305  except:
16306  donothing()
16307 #
16308 # Draw the Phase Analyzer screen
16309 def MakePhAScreen(): # Update the screen with traces and text
16310  global PeakVA, PeakVB, PeakIA, PeakIB
16311  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16312  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB
16313  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16314  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16315  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16316  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
16317  global CMAphase, CMBphase, CMCphase, CMDphase
16318  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth
16319  global COLORsignalband, COLORtext, COLORgrid # The colors
16320  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
16321  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
16322  global X0LPhA # Left top X value
16323  global Y0TPhA # Left top Y value
16324  global GRWPhA # Screenwidth
16325  global GRHPhA # Screenheight
16326  global FontSize, MuxScreenStatus, MuxChan, Mulx, ChopMuxMode
16327  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
16328  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
16329  global SMPfft # number of FFT samples
16330  global TRACEaverage # Number of traces for averageing
16331  global FreqTraceMode # 1 normal 2 max 3 average
16332  global Vdiv, VScale, IScale # Number of vertical divisions
16333  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
16334  global AWGBMode, AWGBIOMode, ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16335  global ShowC1_V, ShowC2_V, ShowC1_I, ShowC2_I, CHA_RC_HP, CHB_RC_HP
16336  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
16337  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
16338  global InOffA, InGainA, InOffB, InGainB
16339  global CurOffA, CurOffB, CurGainA, CurGainB
16340  # Analog Mux channel measurement variables
16341  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
16342  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
16343  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
16344  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
16345  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
16346  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
16347  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
16348  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
16349  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
16350  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
16351  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
16352  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
16353 
16354  # Delete all items on the screen
16355  PhAca.delete(ALL) # remove all items
16356  # SmoothBool = SmoothCurvesBP.get()
16357  # Draw circular grid lines
16358  i = 1
16359  xcenter = GRWPhA/2
16360  ycenter = (GRHPhA/2) + 14
16361  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
16362  VoltsperPixel = float(VScale.get())/Radius
16363  mAperPixel = float(IScale.get())/Radius
16364  TRadius = Radius * Vdiv.get() # 5
16365  x1 = X0LPhA
16366  x2 = X0LPhA + GRWPhA
16367  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
16368  while (i <= Vdiv.get()):
16369  x0 = xcenter - ( i * Radius )
16370  x1 = xcenter + ( i * Radius )
16371  y0 = ycenter - ( i * Radius )
16372  y1 = ycenter + ( i * Radius )
16373  VTxt = '{0:.2f}'.format(float(VScale.get()) * i)
16374  ITxt = '{0:.2f}'.format(float(IScale.get()) * i)
16375  TOffset = xright+(4*FontSize)
16376  PhAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
16377  PhAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
16378  PhAca.create_text(xright, y0, text=str(VTxt), fill=COLORtrace1, anchor="w", font=("arial", FontSize+2 ))
16379  if iat_btn.config('text')[-1] == 'ON' or ibt_btn.config('text')[-1] == 'ON':
16380  PhAca.create_text(TOffset, y0, text=str(ITxt), fill=COLORtrace3, anchor="w", font=("arial", FontSize+2 ))
16381  #
16382  i = i + 1
16383  PhAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
16384  PhAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
16385  RAngle = math.radians(45)
16386  y = TRadius*math.sin(RAngle)
16387  x = TRadius*math.cos(RAngle)
16388  PhAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16389  PhAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16390  PhAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
16391  PhAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16392  PhAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
16393  PhAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
16394  YBot = y1
16395  # calculate phase error due half sample period offset 0.0018
16396  if Two_X_Sample.get() == 0:
16397  if AWGBMode.get() == 2 or AWGBIOMode.get() > 0:
16398  PhErr = 0.001675 * PeakfreqVA
16399  PhErrMA = PhErr
16400  PhErrMB = PhErr
16401  PhErrMC = PhErr
16402  PhErrMD = PhErr
16403  else:
16404  PhErr = 0.0
16405  PhErrMA = PhErr
16406  PhErrMB = PhErr
16407  PhErrMC = PhErr
16408  PhErrMD = PhErr
16409  else:
16410  PhErr = 0.0
16411  PhErrMA = PhErr
16412  PhErrMB = PhErr
16413  PhErrMC = PhErr
16414  PhErrMD = PhErr
16415  if ChopMuxMode.get() > 0:
16416  PhErrMB = 0.0072 * PeakfreqVMB
16417  PhErrMA = 0.0016 * PeakfreqVMA #
16418  PhErrMD = 0.0054 * PeakfreqVMD
16419  PhErrMC = 0.0016 * PeakfreqVMC #
16420 # Draw traces
16421 #
16422  if RefphEntry.get() == "CA-V":
16423  CAVphase = 0.0
16424  CBVphase = PeakphaseVA - PeakphaseVB + PhErr
16425  CAIphase = PeakphaseVA - PeakphaseIA
16426  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
16427  CABVphase = PeakphaseVA - PeakphaseVAB
16428  elif RefphEntry.get() == "CB-V":
16429  CBVphase = 0.0
16430  CAVphase = PeakphaseVB - PeakphaseVA - PhErr
16431  CAIphase = PeakphaseVB - PeakphaseIA - PhErr
16432  CBIphase = PeakphaseVB - PeakphaseIB
16433  CABVphase = PeakphaseVB - PeakphaseVAB
16434  elif RefphEntry.get() == "CA-I":
16435  CAIphase = 0.0
16436  CAVphase = PeakphaseIA - PeakphaseVA
16437  CBVphase = PeakphaseIA - PeakphaseVB + PhErr
16438  CBIphase = PeakphaseIA - PeakphaseIB + PhErr
16439  CABVphase = PeakphaseIA - PeakphaseVAB
16440  elif RefphEntry.get() == "CB-I":
16441  CBIphase = 0.0
16442  CAVphase = PeakphaseIB - PeakphaseVA - PhErr
16443  CBVphase = PeakphaseIB - PeakphaseVB
16444  CAIphase = PeakphaseIB - PeakphaseIA - PhErr
16445  CABVphase = PeakphaseIB - PeakphaseVAB
16446  #
16447  if MuxScreenStatus.get() > 0:
16448  CBVphase = 0.0
16449  if RefphEntry.get() == "CA-V":
16450  CAVphase = 0.0
16451  CMAphase = PeakphaseVA - PeakphaseVMA + PhErr
16452  CMBphase = PeakphaseVA - PeakphaseVMB + PhErr
16453  CMCphase = PeakphaseVA - PeakphaseVMC + PhErr
16454  CMDphase = PeakphaseVA - PeakphaseVMD + PhErr
16455  CAIphase = PeakphaseVA - PeakphaseIA
16456  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
16457  elif RefphEntry.get() == "CB-A":
16458  CMAphase = 0.0
16459  CAVphase = PeakphaseVMA - PeakphaseVA + PhErr
16460  CMBphase = PeakphaseVMA - PeakphaseVMB - PhErrMB
16461  CMCphase = PeakphaseVMA - PeakphaseVMC + PhErrMC
16462  CMDphase = PeakphaseVMA - PeakphaseVMD - PhErrMD
16463  CAIphase = PeakphaseVMA - PeakphaseIA
16464  CBIphase = PeakphaseVMA - PeakphaseIB + PhErr
16465  elif RefphEntry.get() == "CB-B":
16466  CMBphase = 0.0
16467  CAVphase = PeakphaseVMB - PeakphaseVA + PhErr
16468  CMAphase = PeakphaseVMB - PeakphaseVMA + PhErrMD
16469  CMCphase = PeakphaseVMB - PeakphaseVMC + PhErrMB
16470  CMDphase = PeakphaseVMB - PeakphaseVMD + PhErrMC
16471  CAIphase = PeakphaseVMB - PeakphaseIA
16472  CBIphase = PeakphaseVMB - PeakphaseIB + PhErr
16473  elif RefphEntry.get() == "CB-C":
16474  CMCphase = 0.0
16475  CAVphase = PeakphaseVMC - PeakphaseVA + PhErr
16476  CMAphase = PeakphaseVMC - PeakphaseVMA + PhErrMC
16477  CMBphase = PeakphaseVMC - PeakphaseVMB - PhErrMB
16478  CMDphase = PeakphaseVMC - PeakphaseVMD - PhErrMD
16479  CAIphase = PeakphaseVMC - PeakphaseIA
16480  CBIphase = PeakphaseVMC - PeakphaseIB + PhErr
16481  elif RefphEntry.get() == "CB-D":
16482  CMDphase = 0.0
16483  CAVphase = PeakphaseVMD - PeakphaseVA + PhErr
16484  CMAphase = PeakphaseVMD - PeakphaseVMA + PhErrMD
16485  CMBphase = PeakphaseVMD - PeakphaseVMB + PhErrMC
16486  CMCphase = PeakphaseVMD - PeakphaseVMC + PhErrMD
16487  CAIphase = PeakphaseVMD - PeakphaseIA
16488  CBIphase = PeakphaseVMD - PeakphaseIB + PhErr
16489 
16490  if CAVphase > 180:
16491  CAVphase = CAVphase - 360
16492  elif CAVphase < -180:
16493  CAVphase = CAVphase + 360
16494  if CBVphase > 180:
16495  CBVphase = CBVphase - 360
16496  elif CBVphase < -180:
16497  CBVphase = CBVphase + 360
16498  if CAIphase > 180:
16499  CAIphase = CAIphase - 360
16500  elif CAIphase < -180:
16501  CAIphase = CAIphase + 360
16502  if CBIphase > 180:
16503  CBIphase = CBIphase - 360
16504  elif CBIphase < -180:
16505  CBIphase = CBIphase + 360
16506  #
16507  if vat_btn.config('text')[-1] == 'ON':
16508  MagRadius = PeakVA / VoltsperPixel
16509  y1 = ycenter - MagRadius*math.sin(math.radians(CAVphase))
16510  if y1 > 1500:
16511  y1 = xright
16512  elif y1 < -500:
16513  y1 = ycenter - xright
16514  x1 = xcenter + MagRadius*math.cos(math.radians(CAVphase))
16515  if x1 > 1500:
16516  x1 = xright
16517  elif x1 < -500:
16518  x1 = xcenter - xright
16519  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
16520  if MuxScreenStatus.get() == 0:
16521  if vbt_btn.config('text')[-1] == 'ON':
16522  MagRadius = PeakVB / VoltsperPixel
16523  y1 = ycenter - MagRadius*math.sin(math.radians(CBVphase))
16524  if y1 > 1500:
16525  y1 = xright
16526  elif y1 < -500:
16527  y1 = ycenter - xright
16528  x1 = xcenter + MagRadius*math.cos(math.radians(CBVphase))
16529  if x1 > 1500:
16530  x1 = xright
16531  elif x1 < -500:
16532  x1 = xcenter - xright
16533  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
16534  else:
16535  if ShowPB_A.get() > 0:
16536  if CMAphase > 180:
16537  CMAphase = CMAphase - 360
16538  elif CMAphase < -180:
16539  CMAphase = CMAphase + 360
16540  MagRadius = PeakVMA / VoltsperPixel
16541  y1 = ycenter - MagRadius*math.sin(math.radians(CMAphase))
16542  if y1 > 1500:
16543  y1 = xright
16544  elif y1 < -500:
16545  y1 = ycenter - xright
16546  x1 = xcenter + MagRadius*math.cos(math.radians(CMAphase))
16547  if x1 > 1500:
16548  x1 = xright
16549  elif x1 < -500:
16550  x1 = xcenter - xright
16551  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())#
16552  if ShowPB_B.get() > 0:
16553  if CMBphase > 180:
16554  CMBphase = CMBphase - 360
16555  elif CMBphase < -180:
16556  CMBphase = CMBphase + 360
16557  MagRadius = PeakVMB / VoltsperPixel
16558  y1 = ycenter - MagRadius*math.sin(math.radians(CMBphase))
16559  if y1 > 1500:
16560  y1 = xright
16561  elif y1 < -500:
16562  y1 = ycenter - xright
16563  x1 = xcenter + MagRadius*math.cos(math.radians(CMBphase))
16564  if x1 > 1500:
16565  x1 = xright
16566  elif x1 < -500:
16567  x1 = xcenter - xright
16568  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())#
16569  if ShowPB_C.get() > 0:
16570  if CMCphase > 180:
16571  CMCphase = CMCphase - 360
16572  elif CMCphase < -180:
16573  CMCphase = CMCphase + 360
16574  MagRadius = PeakVMC / VoltsperPixel
16575  y1 = ycenter - MagRadius*math.sin(math.radians(CMCphase))
16576  if y1 > 1500:
16577  y1 = xright
16578  elif y1 < -500:
16579  y1 = ycenter - xright
16580  x1 = xcenter + MagRadius*math.cos(math.radians(CMCphase))
16581  if x1 > 1500:
16582  x1 = xright
16583  elif x1 < -500:
16584  x1 = xcenter - xright
16585  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())#
16586  if ShowPB_D.get() > 0:
16587  if CMDphase > 180:
16588  CMDphase = CMDphase - 360
16589  elif CMDphase < -180:
16590  CMDphase = CMDphase + 360
16591  MagRadius = PeakVMD / VoltsperPixel
16592  y1 = ycenter - MagRadius*math.sin(math.radians(CMDphase))
16593  if y1 > 1500:
16594  y1 = xright
16595  elif y1 < -500:
16596  y1 = ycenter - xright
16597  x1 = xcenter + MagRadius*math.cos(math.radians(CMDphase))
16598  if x1 > 1500:
16599  x1 = xright
16600  elif x1 < -500:
16601  x1 = xcenter - xright
16602  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())#
16603  if iat_btn.config('text')[-1] == 'ON':
16604  MagRadius = PeakIA / mAperPixel
16605  y1 = ycenter - MagRadius*math.sin(math.radians(CAIphase))
16606  if y1 > 1500:
16607  y1 = xright
16608  elif y1 < -500:
16609  y1 = ycenter - xright
16610  x1 = xcenter + MagRadius*math.cos(math.radians(CAIphase))
16611  if x1 > 1500:
16612  x1 = xright
16613  elif x1 < -500:
16614  x1 = xcenter - xright
16615  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace3, arrow="last", width=TRACEwidth.get())
16616  if ibt_btn.config('text')[-1] == 'ON':
16617  MagRadius = PeakIB / mAperPixel
16618  y1 = ycenter - MagRadius*math.sin(math.radians(CBIphase))
16619  if y1 > 1500:
16620  y1 = xright
16621  elif y1 < -500:
16622  y1 = ycenter - xright
16623  x1 = xcenter + MagRadius*math.cos(math.radians(CBIphase))
16624  if x1 > 1500:
16625  x1 = xright
16626  elif x1 < -500:
16627  x1 = xcenter - xright
16628  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())
16629  if MuxScreenStatus.get() == 0:
16630  if vabt_btn.config('text')[-1] == 'ON':
16631  MagRadius = PeakVAB / VoltsperPixel
16632 
16633  y1 = ycenter - MagRadius*math.sin(math.radians(CABVphase))
16634  if y1 > 1500:
16635  y1 = xright
16636  elif y1 < -500:
16637  y1 = ycenter - xright
16638  x1 = xcenter + MagRadius*math.cos(math.radians(CABVphase))
16639  if x1 > 1500:
16640  x1 = xright
16641  elif x1 < -500:
16642  x1 = xcenter - xright
16643  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
16644 # display warning if input out of range
16645  if OverRangeFlagA == 1:
16646  x = X0LPhA+GRWPhA+10
16647  y = Y0TPhA+GRHPhA-40
16648  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
16649  PhAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
16650  if OverRangeFlagB == 1:
16651  x = X0LPhA+GRWPhA+10
16652  y = Y0TPhA+GRHPhA-10
16653  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
16654  PhAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
16655 # General information on top of the grid
16656  txt = " Sample rate: " + str(SAMPLErate)
16657  txt = txt + " FFT samples: " + str(SMPfft)
16658  txt = txt + " " + FFTwindowname
16659 
16660  x = X0LPhA
16661  y = 12
16662  idTXT = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
16663  #
16664  x = X0LPhA + GRWPhA + 4
16665  y = 24
16666  if ChopMuxMode.get() == 0:
16667  txt = "CA " + ' {0:.3f} '.format(PeakVA) + " RMS V"
16668  TXT9 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
16669  y = y + 24
16670  if MuxScreenStatus.get() == 0:
16671  txt = "CB " + ' {0:.3f} '.format(PeakVB) + " RMS V"
16672  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16673  y = y + 24
16674  else:
16675  if ShowPB_A.get() > 0:
16676  txt = "Mux A " + ' {0:.3f} '.format(PeakVMA) + " RMS V"
16677  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16678  y = y + 24
16679  if ShowPB_B.get() > 0:
16680  txt = "Mux B " + ' {0:.3f} '.format(PeakVMB) + " RMS V"
16681  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
16682  y = y + 24
16683  if ShowPB_C.get() > 0:
16684  txt = "Mux C " + ' {0:.3f} '.format(PeakVMC) + " RMS V"
16685  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
16686  y = y + 24
16687  if ShowPB_D.get() > 0:
16688  txt = "Mux D " + ' {0:.3f} '.format(PeakVMD) + " RMS V"
16689  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16690  y = y + 24
16691  if iat_btn.config('text')[-1] == 'ON':
16692  txt = "CA " + ' {0:.2f} '.format(PeakIA) + " RMS mA"
16693  TXT11 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
16694  y = y + 24
16695  if ibt_btn.config('text')[-1] == 'ON':
16696  txt = "CB " + ' {0:.2f} '.format(PeakIB) + " RMS mA"
16697  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16698  y = y + 24
16699  if ChopMuxMode.get() == 0:
16700  txt = "CA V Phase " + ' {0:.1f} '.format(CAVphase) + " Degrees"
16701  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
16702  y = y + 24
16703  if MuxScreenStatus.get() == 0:
16704  txt = "CB V Phase " + ' {0:.1f} '.format(CBVphase) + " Degrees"
16705  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16706  y = y + 24
16707  else:
16708  if ShowPB_A.get() > 0:
16709  txt = "Mux A Phase " + ' {0:.1f} '.format(CMAphase) + " Degrees"
16710  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16711  y = y + 24
16712  if ShowPB_B.get() > 0:
16713  txt = "Mux B Phase " + ' {0:.1f} '.format(CMBphase) + " Degrees"
16714  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
16715  y = y + 24
16716  if ShowPB_C.get() > 0:
16717  txt = "Mux C Phase " + ' {0:.1f} '.format(CMCphase) + " Degrees"
16718  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
16719  y = y + 24
16720  if ShowPB_D.get() > 0:
16721  txt = "Mux D Phase " + ' {0:.1f} '.format(CMDphase) + " Degrees"
16722  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16723  y = y + 24
16724  if iat_btn.config('text')[-1] == 'ON':
16725  txt = "CA I Phase " + ' {0:.1f} '.format(CAIphase) + " Degrees"
16726  TXT15 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
16727  y = y + 24
16728  if ibt_btn.config('text')[-1] == 'ON':
16729  txt = "CB I Phase " + ' {0:.1f} '.format(CBIphase) + " Degrees"
16730  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16731  y = y + 24
16732  #
16733  if ChopMuxMode.get() == 0:
16734  txt = "CA-V Freq " + ' {0:.1f} '.format(PeakfreqVA) + " Hertz"
16735  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16736  y = y + 24
16737  else:
16738  txt = "Mux A Freq " + ' {0:.1f} '.format(PeakfreqVMA) + " Hertz"
16739  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16740  y = y + 24
16741 #
16742  txt = " "
16743 # print time domin measured period and frequency of displayed channels
16744  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
16745  if ETSDisp.get() > 0:
16746  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
16747  else:
16748  FindRisingEdge(VBuffA,VBuffB)
16749  if ShowC1_V.get() == 1:
16750  if MeasAHW.get() == 1:
16751  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
16752  if MeasALW.get() == 1:
16753  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
16754  if MeasADCy.get() == 1:
16755  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
16756  if MeasAPER.get() == 1:
16757  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
16758  if MeasAFREQ.get() == 1:
16759  txt = txt + " CA Freq = "
16760  ChaF = float(CHAfreq*Mulx)
16761  if ChaF < 1000:
16762  V1String = ' {0:.2f} '.format(ChaF)
16763  txt = txt + str(V1String) + " Hz "
16764  if ChaF > 1000 and ChaF < 1000000:
16765  V1String = ' {0:.2f} '.format(ChaF/1000)
16766  txt = txt + str(V1String) + " KHz "
16767  if ChaF > 1000000:
16768  V1String = ' {0:.2f} '.format(ChaF/1000000)
16769  txt = txt + str(V1String) + " MHz "
16770  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
16771  if ShowC2_V.get() == 1:
16772  if MeasBHW.get() == 1:
16773  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
16774  if MeasBLW.get() == 1:
16775  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
16776  if MeasBDCy.get() == 1:
16777  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
16778  if MeasBPER.get() == 1:
16779  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
16780  if MeasBFREQ.get() == 1:
16781  txt = txt + " CB Freq = "
16782  ChaF = float(CHBfreq*Mulx)
16783  if ChaF < 1000:
16784  V1String = ' {0:.2f} '.format(ChaF)
16785  txt = txt + str(V1String) + " Hz "
16786  if ChaF > 1000 and ChaF < 1000000:
16787  V1String = ' {0:.2f} '.format(ChaF/1000)
16788  txt = txt + str(V1String) + " KHz "
16789  if ChaF > 1000000:
16790  V1String = ' {0:.2f} '.format(ChaF/1000000)
16791  txt = txt + str(V1String) + " MHz "
16792  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
16793  if MuxScreenStatus.get() == 0:
16794  if MeasPhase.get() == 1:
16795  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
16796  if MeasDelay.get() == 1:
16797  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
16798 
16799  x = X0LPhA
16800  y = YBot + int(2.5 *FontSize) #
16801  TXT18 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16802  txt = " "
16803  if ShowC1_V.get() == 1:
16804  # Channel A information
16805  if CHA_RC_HP.get() == 1:
16806  txt = "CHA: HP "
16807  else:
16808  txt = "CHA: "
16809  if MeasDCV1.get() == 1:
16810  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
16811  if MeasMaxV1.get() == 1:
16812  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
16813  if MeasTopV1.get() == 1:
16814  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
16815  if MeasMinV1.get() == 1:
16816  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
16817  if MeasBaseV1.get() == 1:
16818  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
16819  if MeasMidV1.get() == 1:
16820  MidV1 = (MaxV1+MinV1)/2.0
16821  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
16822  if MeasPPV1.get() == 1:
16823  PPV1 = MaxV1-MinV1
16824  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
16825  if MeasRMSV1.get() == 1:
16826  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
16827  if MeasRMSVA_B.get() == 1:
16828  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
16829  if MeasDiffAB.get() == 1:
16830  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
16831  if MeasUserA.get() == 1:
16832  try:
16833  TempValue = eval(UserAString)
16834  V1String = ' {0:.4f} '.format(TempValue)
16835  except:
16836  V1String = "####"
16837  txt = txt + UserALabel + " = " + V1String
16838  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
16839  txt = "CHA: "
16840  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
16841  txt = txt + "CHA: "
16842 
16843  if ShowC1_I.get() == 1:
16844  if MeasDCI1.get() == 1:
16845  V1String = ' {0:.2f} '.format(DCI1)
16846  txt = txt + " AvgI = " + V1String
16847  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
16848  try:
16849  Resvalue = (DCV1/DCI1)*1000
16850  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
16851  except:
16852  txt = txt + " Res = OverRange"
16853  if MeasMaxI1.get() == 1:
16854  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
16855  if MeasMinI1.get() == 1:
16856  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
16857  if MeasMidI1.get() == 1:
16858  MidI1 = (MaxI1+MinI1)/2.0
16859  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
16860  if MeasPPI1.get() == 1:
16861  PPI1 = MaxI1-MinI1
16862  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
16863  if MeasRMSI1.get() == 1:
16864  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
16865 
16866  x = X0LPhA
16867  y = YBot + int(4*FontSize) #
16868  TXT19 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16869  txt= " "
16870  # Channel B information
16871  if MuxScreenStatus.get() == 1:
16872  txt = "CHB-Mux: "
16873  if Show_CBA.get() > 0:
16874  FindRisingEdge(VBuffA,VBuffMA)
16875  elif Show_CBB.get() > 0:
16876  FindRisingEdge(VBuffA,VBuffMB)
16877  elif Show_CBC.get() > 0:
16878  FindRisingEdge(VBuffA,VBuffMC)
16879  elif Show_CBD.get() > 0:
16880  FindRisingEdge(VBuffA,VBuffMD)
16881  if MeasPhase.get() == 1:
16882  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
16883  if MeasDelay.get() == 1:
16884  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
16885  if MeasUserB.get() == 1:
16886  try:
16887  TempValue = eval(UserBString)
16888  V1String = ' {0:.4f} '.format(TempValue)
16889  except:
16890  V1String = "####"
16891  txt = txt + UserBLabel + " = " + V1String
16892  if ShowC2_V.get() == 1:
16893  if CHB_RC_HP.get() == 1:
16894  txt = "CHB: HP "
16895  else:
16896  txt = "CHB: "
16897  if MeasDCV2.get() == 1:
16898  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
16899  if MeasMaxV2.get() == 1:
16900  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
16901  if MeasTopV2.get() == 1:
16902  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
16903  if MeasMinV2.get() == 1:
16904  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
16905  if MeasBaseV2.get() == 1:
16906  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
16907  if MeasMidV2.get() == 1:
16908  MidV2 = (MaxV2+MinV2)/2.0
16909  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
16910  if MeasPPV2.get() == 1:
16911  PPV2 = MaxV2-MinV2
16912  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
16913  if MeasRMSV2.get() == 1:
16914  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
16915  if MeasDiffBA.get() == 1:
16916  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
16917  if MeasUserB.get() == 1:
16918  try:
16919  TempValue = eval(UserBString)
16920  V1String = ' {0:.4f} '.format(TempValue)
16921  except:
16922  V1String = "####"
16923  txt = txt + UserBLabel + " = " + V1String
16924  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
16925  txt = "CHB: "
16926  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
16927  txt = txt + "CHB: "
16928  if ShowC2_I.get() == 1:
16929  if MeasDCI2.get() == 1:
16930  V1String = ' {0:.2f} '.format(DCI2)
16931  txt = txt + " AvgI = " + V1String
16932  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
16933  try:
16934  Resvalue = (DCV2/DCI2)*1000
16935  R1String = ' {0:.1f} '.format(Resvalue)
16936  txt = txt + " Res = " + R1String
16937  except:
16938  txt = txt + " Res = OverRange"
16939  if MeasMaxI2.get() == 1:
16940  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
16941  if MeasMinI2.get() == 1:
16942  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
16943  if MeasMidI2.get() == 1:
16944  MidI2 = (MaxI2+MinI2)/2.0
16945  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
16946  if MeasPPI2.get() == 1:
16947  PPI2 = MaxI2-MinI2
16948  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
16949  if MeasRMSI2.get() == 1:
16950  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
16951 
16952  x = X0LPhA
16953  y = YBot + int(5.5 *FontSize) #
16954  TXT20 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16955 #
16957  global PeakVA, PeakVB, PeakIA, PeakIB
16958  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16959  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16960  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
16961  global CMAphase, CMBphase, CMCphase, CMDphase
16962  global MuxScreenStatus, AppendPhAData, PhADatafilename
16963  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
16964  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16965 
16966  # open file to save data
16967  if AppendPhAData.get() == 0:
16968  PhADatafilename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
16969  DataFile = open(PhADatafilename, 'a')
16970  DataFile.write( 'Amplitude, Phase, @ ' + str(PeakfreqVA) + ' Hertz\n')
16971 
16972  if vat_btn.config('text')[-1] == 'ON':
16973  DataFile.write( str(PeakVA) + ', ' + str(CAVphase) + ', CA-V\n')
16974  if MuxScreenStatus.get() == 0:
16975  if vbt_btn.config('text')[-1] == 'ON':
16976  DataFile.write( str(PeakVB) + ', ' + str(CBVphase) + ', CB-V\n')
16977  else:
16978  if ShowPB_A.get() > 0:
16979  DataFile.write( str(PeakVMA) + ', ' + str(CMAphase) + ', Mux A\n')
16980  if ShowPB_B.get() > 0:
16981  DataFile.write( str(PeakVMB) + ', ' + str(CMBphase) + ', Mux B\n')
16982  if ShowPB_C.get() > 0:
16983  DataFile.write( str(PeakVMC) + ', ' + str(CMCphase) + ', Mux C\n')
16984  if ShowPB_D.get() > 0:
16985  DataFile.write( str(PeakVMD) + ', ' + str(CMDphase) + ', Mux D\n')
16986  if iat_btn.config('text')[-1] == 'ON':
16987  DataFile.write( str(PeakIA) + ', ' + str(CAIphase) + ', CA-I\n')
16988  if ibt_btn.config('text')[-1] == 'ON':
16989  DataFile.write( str(PeakIB) + ', ' + str(CBIphase) + ', CB-I\n')
16990  DataFile.close()
16991 #
16993  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth, PhAPlotMode
16994  global COLORsignalband, COLORtext, COLORgrid, SmoothCurves # The colors
16995  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
16996  global GRWPhA, GRHPhA, X0LPhA, Vdiv, VScale, IScale
16997 # open file to read data from
16998  filename = askopenfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
16999  i = 1
17000  xcenter = GRWPhA/2
17001  ycenter = (GRHPhA/2) + 14
17002  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
17003  VoltsperPixel = float(VScale.get())/Radius
17004  mAperPixel = float(IScale.get())/Radius
17005  TRadius = Radius * Vdiv.get() # 5
17006  x1 = X0LPhA
17007  x2 = X0LPhA + GRWPhA
17008  PhATrace = []
17009 # Read values from CVS file
17010  try:
17011  CSVFile = open(filename)
17012  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
17013  CSVFile.seek(0)
17014  csv_f = csv.reader(CSVFile, dialect)
17015  for row in csv_f:
17016  try:
17017  PeakMag = float(row[0])
17018  PeakPhase = float(row[1])
17019  if row[2] == "CA-I" or row[2] == "CB-I":
17020  MagRadius = PeakMag / mAperPixel
17021  else:
17022  MagRadius = PeakMag / VoltsperPixel
17023 
17024  y1 = ycenter - MagRadius*math.sin(math.radians(PeakPhase))
17025  if y1 > 1500:
17026  y1 = xright
17027  elif y1 < -500:
17028  y1 = ycenter - xright
17029  x1 = xcenter + MagRadius*math.cos(math.radians(PeakPhase))
17030  if x1 > 1500:
17031  x1 = xright
17032  elif x1 < -500:
17033  x1 = xcenter - xright
17034  if PhAPlotMode.get() == 0:
17035  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
17036  else:
17037  PhATrace.append(x1)
17038  PhATrace.append(y1)
17039  except:
17040  print( 'skipping non-numeric row')
17041  if PhAPlotMode.get() == 1:
17042  PhAca.create_line(PhATrace, fill=COLORtrace5, smooth=SmoothCurves.get(), splinestep=5, width=TRACEwidth.get())
17043  CSVFile.close()
17044  except:
17045  showwarning("WARNING","No such file found or wrong format!")
17046 #
17047 #
17048 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
17049  global FFTmemoryA, FFTresultA, SMPfft
17050  global FFTmemoryB, FFTresultB
17051  global PhaseA, PhaseB, freqwindow
17052  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
17053 
17054  # Set the TRACEsize variable
17055  if ShowC1_VdB.get() == 1:
17056  TRACEsize = len(FFTresultA) # Set the trace length
17057  elif ShowC2_VdB.get() == 1:
17058  TRACEsize = len(FFTresultB)
17059  if TRACEsize == 0: # If no trace, skip rest of this routine
17060  return()
17061 # ask if save as magnitude or dB
17062  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
17063  # Make the file name and open it
17064  if dB == 0:
17065  PSD = askyesno("Mag/Root Hz? ","Save Mag in V/sqrt Hz? (yes) or (No):\n", parent=freqwindow)
17066  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
17067  filename = "Spectrum-" + tme
17068  filename = filename + ".csv"
17069  # open file to save data
17070  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
17071  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
17072  DataFile = open(filename,'a') # Open output file
17073  HeaderString = 'Frequency-#, '
17074  if ShowC1_VdB.get() == 1:
17075  if dB == 1:
17076  HeaderString = HeaderString + 'CA-dB, '
17077  if dB == 0:
17078  HeaderString = HeaderString + 'CA-Mag, '
17079  if ShowC2_VdB.get() == 1:
17080  if dB == 1:
17081  HeaderString = HeaderString + 'CB-dB, '
17082  if dB == 0:
17083  HeaderString = HeaderString + 'CB-Mag, '
17084  if ShowC1_P.get() == 1:
17085  HeaderString = HeaderString + 'Phase A-B, '
17086  if ShowC2_P.get() == 1:
17087  HeaderString = HeaderString + 'Phase B-A, '
17088  HeaderString = HeaderString + '\n'
17089  DataFile.write( HeaderString )
17090 
17091  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
17092  n = 0
17093 
17094  while n < TRACEsize:
17095  F = n * FBinWidth
17096  txt = str(F)
17097  if ShowC1_VdB.get() == 1:
17098  V = 10 * math.log10(float(FFTresultA[n])) #
17099  if dB == 0:
17100  V = 10.0**(V/20.0) # RMS Volts
17101  if PSD == 1:
17102  V = V/math.sqrt(FBinWidth) # per root Hz
17103  txt = txt + "," + str(V)
17104  if ShowC2_VdB.get() == 1:
17105  V = 10 * math.log10(float(FFTresultB[n])) #
17106  if dB == 0:
17107  V = 10.0**(V/20.0)# RMS Volts
17108  if PSD == 1:
17109  V = V/math.sqrt(FBinWidth) # per root Hz
17110  txt = txt + "," + str(V)
17111  if ShowC1_P.get() == 1:
17112  RelPhase = PhaseA[n]-PhaseB[n]
17113  if RelPhase > 180:
17114  RelPhase = RelPhase - 360
17115  elif RelPhase < -180:
17116  RelPhase = RelPhase + 360
17117  txt = txt + "," + str(RelPhase)
17118  if ShowC2_P.get() == 1:
17119  RelPhase = PhaseB[n]-PhaseA[n]
17120  if RelPhase > 180:
17121  RelPhase = RelPhase - 360
17122  elif RelPhase < -180:
17123  RelPhase = RelPhase + 360
17124  txt = txt + "," + str(RelPhase)
17125  txt = txt + "\n"
17126  DataFile.write(txt)
17127  n = n + 1
17128 
17129  DataFile.close() # Close the file
17130 
17132 def MakeFreqScreen(): # Update the screen with traces and text
17133  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
17134  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
17135  global PeakxM, PeakyM, PeakMdb, PeakfreqM
17136  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
17137  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
17138  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
17139  global COLORgrid # The colors
17140  global COLORsignalband, COLORtext
17141  global COLORtrace1, COLORtrace2
17142  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
17143  global DBdivindex # Index value
17144  global DBdivlist # dB per division list
17145  global DBlevel # Reference level
17146  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
17147  global X0LF # Left top X value
17148  global Y0TF # Left top Y value
17149  global GRWF # Screenwidth
17150  global GRHF # Screenheight
17151  global FontSize
17152  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
17153  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
17154  global SMPfft # number of FFT samples
17155  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17156  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
17157  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
17158  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp, ShowAWGASA, ShowAWGBSA
17159  global ShowFCur, ShowdBCur, FCursor, dBCursor
17160  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
17161  global T1PRline, T2PRline, TAFline, TBFline
17162  global TRACEaverage # Number of traces for averageing
17163  global FreqTraceMode # 1 normal 2 max 3 average
17164  global Vdiv # Number of vertical divisions
17165 
17166  # Delete all items on the screen
17167  MarkerFreqNum = 0
17168  FBinWidth = float(SAMPLErate / 2.0) / (SMPfft - 1) # Frequency step per sample
17169  Freqca.delete(ALL) # remove all items
17170  try:
17171  StartFrequency = float(StartFreqEntry.get())
17172  except:
17173  StartFreqEntry.delete(0,"end")
17174  StartFreqEntry.insert(0,100)
17175  StartFrequency = 100
17176  try:
17177  StopFrequency = float(StopFreqEntry.get())
17178  except:
17179  StopFreqEntry.delete(0,"end")
17180  StopFreqEntry.insert(0,10000)
17181  StopFrequency = 10000
17182  try:
17183  Phasecenter = int(PhCenFreqEntry.get())
17184  RelPhaseCenter.set(Phasecenter)
17185  except:
17186  PhCenFreqEntry.delete(0,"end")
17187  PhCenFreqEntry.insert(0,0)
17188  RelPhaseCenter.set(0)
17189  Phasecenter = 0
17190  # Draw horizontal grid lines
17191  i = 0
17192  x1 = X0LF
17193  x2 = X0LF + GRWF
17194  if SAVScale.get() == 0: # In dB
17195  while (i <= Vdiv.get()):
17196  y = Y0TF + i * GRHF/Vdiv.get()
17197  Dline = [x1,y,x2,y]
17198  if i == 0 or i == Vdiv.get():
17199  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17200  else:
17201  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17202  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
17203  Vaxis_label = str(Vaxis_value)
17204  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17205  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
17206  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
17207  Vaxis_value = Vaxis_value + Phasecenter
17208  Vaxis_label = str(Vaxis_value)
17209  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
17210  i = i + 1
17211  else: # In rms V
17212  if SAVScale.get() == 2: # Log Scale
17213  try:
17214  LogVStop = math.log10(SAvertmax)
17215  except:
17216  LogVStop = 0.0
17217  try:
17218  LogVStart = math.log10(SAvertmin)
17219  except:
17220  LogVStart = -10
17221  LogVpixel = (LogVStart - LogVStop) / GRHF
17222  NumDec = LogVStart - LogVStop # number of major grids
17223  Gridpixel = GRHF/NumDec # number of pixels per major grid
17224  V = NumDec
17225  while V <= 0: # Major Grid lines
17226  try:
17227  LogV = math.log10(10**V) # convet to log Volts
17228  y = Y0TF + (LogV/LogVpixel)
17229  except:
17230  y = Y0TF
17231  Dline = [x1,y,x2,y]
17232  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17233  LNum = LogVStop + V
17234  if LNum == 1.0:
17235  axis_label = "10.0"
17236  elif LNum == 0:
17237  axis_label = "1.0"
17238  elif LNum == -1:
17239  axis_label = "100mV"
17240  elif LNum == -2:
17241  axis_label = "10mV"
17242  elif LNum == -3:
17243  axis_label = "1mV"
17244  elif LNum == -4:
17245  axis_label = "100uV"
17246  elif LNum == -5:
17247  axis_label = "10uV"
17248  elif LNum == -6:
17249  axis_label = "1uV"
17250  elif LNum == -7:
17251  axis_label = "100nV"
17252  elif LNum == -8:
17253  axis_label = "10nV"
17254  else:
17255  axis_label = str(LogVStart+V)
17256  print(LNum)
17257  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17258  J = 2
17259  while J < 10: # Minor Grid lines
17260  ym = y + (Gridpixel*math.log10(J))
17261  Dline = [x1,ym,x2,ym]
17262  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17263  J = J + 1
17264  V = V + 1
17265  else: # Linear Scale
17266  i = 0
17267  Vper = (SAvertmax - SAvertmin) / Vdiv.get()
17268  while (i < Vdiv.get()+1):
17269  y = Y0TF + i * GRHF/Vdiv.get()
17270  Dline = [x1,y,x2,y]
17271  if i == 0 or i == Vdiv.get():
17272  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17273  else:
17274  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17275  axis_value = (SAvertmax - (i * Vper))
17276  axis_label = ' {0:.3f} '.format(axis_value) # str(axis_value)
17277  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17278  i = i + 1
17279  # Draw vertical grid lines
17280  i = 0
17281  y1 = Y0TF
17282  y2 = Y0TF + GRHF
17283  if HScale.get() == 1:
17284  F = 1.0
17285  LogFStop = math.log10(StopFrequency)
17286  try:
17287  LogFStart = math.log10(StartFrequency)
17288  except:
17289  LogFStart = 0.0
17290  LogFpixel = (LogFStop - LogFStart) / GRWF
17291  # draw left and right edges
17292  while F <= StopFrequency:
17293  if F >= StartFrequency:
17294  try:
17295  LogF = math.log10(F) # convet to log Freq
17296  x = X0LF + (LogF - LogFStart)/LogFpixel
17297  except:
17298  x = X0LF
17299  Dline = [x,y1,x,y2]
17300  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
17301  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17302  axis_label = str(F)
17303  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
17304  else:
17305  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17306 
17307  if F < 10:
17308  F = F + 1
17309  elif F < 100:
17310  F = F + 10
17311  elif F < 1000:
17312  F = F + 100
17313  elif F < 1000:
17314  F = F + 100
17315  elif F < 10000:
17316  F = F + 1000
17317  elif F < 100000:
17318  F = F + 10000
17319  elif F < 200000:
17320  F = F + 10000
17321  else:
17322  Freqdiv = (StopFrequency - StartFrequency) / 10
17323  while (i < 11):
17324  x = X0LF + i * GRWF/10.0
17325  Dline = [x,y1,x,y2]
17326  if i == 0 or i == 10:
17327  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17328  else:
17329  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17330  axis_value = (StartFrequency + (i * Freqdiv))
17331  axis_label = str(axis_value)
17332  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
17333  i = i + 1
17334  # Draw X - Y cursors if needed
17335  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17336  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
17337  # Vertical conversion factors (level dBs) and border limits
17338  YVconv = float(GRHF) / (SAvertmax - SAvertmin) #
17339  YVc = float(Y0TF) + YVconv * SAvertmax
17340  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17341  if ShowFCur.get() > 0:
17342  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
17343  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
17344  # Horizontal conversion factors (frequency Hz) and border limits
17345  if HScale.get() == 1:
17346  LogFStop = math.log10(StopFrequency)
17347  try:
17348  LogFStart = math.log10(StartFrequency)
17349  except:
17350  LogFStart = 0.0
17351  LogFpixel = (LogFStop - LogFStart) / GRWF
17352  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
17353  else:
17354  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17355  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
17356  XFString = ' {0:.2f} '.format(xfreq)
17357  V_label = XFString + " Hz"
17358  Freqca.create_text(FCursor+1, Y0TF+GRHF+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
17359  #Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
17360 #
17361  if ShowdBCur.get() > 0:
17362  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
17363  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
17364  if SAVScale.get() == 0: # In dB
17365  yvdB = ((Yc-dBCursor)/Yconv)
17366  VdBString = ' {0:.1f} '.format(yvdB)
17367  V_label = VdBString + " dBV"
17368  elif SAVScale.get() == 1: # Lin Scale
17369  yvdB = ((YVc-dBCursor)/YVconv)
17370  VdBString = ' {0:.3f} '.format(yvdB)
17371  V_label = VdBString + " Vrms"
17372  else: # Log Scale
17373  LogVpixel = (LogVStop - LogVStart) / GRHF
17374  Vlog = ((YVc - dBCursor) * LogVpixel) + LogVStart
17375  yvdB = 10**Vlog
17376  VdBString = ' {:.2e} '.format(yvdB)
17377  V_label = VdBString + " Vrms"
17378 
17379  Freqca.create_text(X0LF+GRWF-5, dBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
17380  #
17381  SmoothBool = SmoothCurvesSA.get()
17382  # Draw traces
17383  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
17384  # Write the trace CHA
17385  if OverRangeFlagA == 1:
17386  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17387  else:
17388  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17389  if ShowMarker.get() > 0:
17390  k = 1
17391  while k <= HarmonicMarkers.get():
17392  FreqA = k*PeakIndexA*Fsample
17393  #
17394  if SAVScale.get() == 0: # In dB
17395  if SAVPSD.get() == 1:
17396  try:
17397  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])/math.sqrt(FBinWidth))
17398  except:
17399  dbA = -100
17400  else:
17401  try:
17402  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k]))
17403  except:
17404  dbA = -100
17405  if ShowMarker.get() == 2 and k > 1:
17406  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17407  else:
17408  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
17409  yA = Yc - Yconv * dbA
17410  else: # Volts Scale
17411  try:
17412  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])) # Convert power to DBs
17413  except:
17414  dbA = -100
17415  V = 10.0**(dbA/20.0)# convert back to RMS Volts
17416  PeakV = 10.0**(PeakdbA/20.0)# convert back to RMS Volts
17417  if SAVPSD.get() == 1: # per root Hz
17418  V = V/math.sqrt(FBinWidth)
17419  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
17420  if SAVScale.get() == 2: # Log Scale
17421  LogVpixel = (LogVStop - LogVStart) / GRHF
17422  try:
17423  LogV = math.log10(V) # convet to log Volts
17424  yA = YVc - (LogV - LogVStart)/LogVpixel
17425  except:
17426  yA = YVc - YVconv * V
17427  if ShowMarker.get() == 2 and k > 1:
17428  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17429  else:
17430  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
17431  else: # Lin Scale
17432  if ShowMarker.get() == 2 and k > 1:
17433  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17434  else:
17435  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
17436  yA = YVc - YVconv * V
17437  #
17438  if HScale.get() == 1:
17439  try:
17440  LogF = math.log10(FreqA) # convet to log Freq
17441  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
17442  except:
17443  xA = X0LF
17444  else:
17445  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
17446 
17447  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
17448  k = k + 1
17449 
17450  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
17451  # Write the trace CHB
17452  if OverRangeFlagB == 1:
17453  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17454  else:
17455  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17456  if ShowMarker.get() > 0:
17457  k = 1
17458  while k <= HarmonicMarkers.get():
17459  FreqB = k*PeakIndexB*Fsample
17460  #
17461  if SAVScale.get() == 0: # In dB
17462  if SAVPSD.get() == 1:
17463  try:
17464  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])/math.sqrt(FBinWidth))
17465  except:
17466  dbB = -100
17467  else:
17468  try:
17469  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k]))
17470  except:
17471  dbb = -100
17472  if ShowMarker.get() == 2 and k > 1:
17473  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17474  else:
17475  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
17476  yB = Yc - Yconv * dbB
17477  else: # Volts Scale
17478  try:
17479  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])) # Convert power to DBs
17480  except:
17481  dbB = -100
17482  V = 10.0**(dbB/20.0)# convert back to RMS Volts
17483  PeakV = 10.0**(PeakdbB/20.0)# convert back to RMS Volts
17484  if SAVPSD.get() == 1: # per root Hz
17485  V = V/math.sqrt(FBinWidth)
17486  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
17487  if SAVScale.get() == 2: # Log Scale
17488  LogVpixel = (LogVStop - LogVStart) / GRHF
17489  try:
17490  LogV = math.log10(V) # convet to log Volts
17491  yB = YVc - (LogV - LogVStart)/LogVpixel
17492  except:
17493  yB = YVc - YVconv * V
17494  if ShowMarker.get() == 2 and k > 1:
17495  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17496  else:
17497  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
17498  else: # Lin Scale
17499  if ShowMarker.get() == 2 and k > 1:
17500  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17501  else:
17502  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
17503  yB = YVc - YVconv * V
17504  #
17505  if HScale.get() == 1:
17506  try:
17507  LogF = math.log10(FreqB) # convet to log Freq
17508  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
17509  except:
17510  xB = X0LF
17511  else:
17512  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
17513 
17514  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
17515  k = k + 1
17516 #
17517  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
17518  # Write the phase trace A-B
17519  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17520  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
17521  # Write the phase trace A-B
17522  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17523  if ShowAWGASA.get() > 0 and len(TAFline) > 4: # Write the AWG trace A if active
17524  Freqca.create_line(TAFline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17525  if ShowAWGBSA.get() > 0 and len(TBFline) > 4: # Write the AWG trace B if active
17526  Freqca.create_line(TBFline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17527  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
17528  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17529  if ShowMarker.get() == 1:
17530  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
17531  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
17532  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
17533  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17534  if ShowMarker.get() == 1:
17535  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
17536  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
17537  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
17538  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17539  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
17540  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17541  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
17542  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17543  if ShowMarker.get() ==1:
17544  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
17545  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
17546  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
17547  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17548  if ShowMarker.get() ==1:
17549  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
17550  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
17551  # General information on top of the grid
17552 
17553  txt = " Sample rate: " + str(SAMPLErate)
17554  txt = txt + " FFT samples: " + str(SMPfft)
17555 
17556  txt = txt + " " + FFTwindowname
17557 
17558  x = X0LF
17559  y = 12
17560  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17561 
17562  # Start and stop frequency and dB/div and trace mode
17563  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
17564  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
17565  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
17566  if FFTwindow.get() < 7:
17567  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
17568  else:
17569  txt = txt + " FFT Bandwidth = ???"
17570 
17571  x = X0LF
17572  y = Y0TF+GRHF+23
17573  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17574 
17575  if FreqTraceMode.get() == 1:
17576  txt ="Normal mode "
17577 
17578  if FreqTraceMode.get() == 2:
17579  txt = "Peak hold mode "
17580 
17581  if FreqTraceMode.get() == 3:
17582  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
17583 
17584  if ZEROstuffing.get() > 0:
17585  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
17586  # Runstatus and level information
17587  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
17588  txt = txt + " Stopped "
17589  elif SingleShotSA.get() == 1:
17590  txt = txt + " Single Shot Trace "
17591  else:
17592  if FreqDisp.get() == 1:
17593  txt = txt + " Running "
17594  else:
17595  txt = txt + " Display off "
17596  x = X0LF
17597  y = Y0TF+GRHF+34
17598  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17599 
17601  global SMPfft, FFTwindow
17602  global SMPfftpwrTwo, BodeDisp
17603  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
17604 
17605  # First some subroutines to set specific variables
17606  if BodeDisp.get() == 0:
17607  if FFTwindow.get() != 8:
17608  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
17609 
17611  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
17612  TRACEresetFreq = True # Clear the memory for averaging or peak
17613  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
17614  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
17615 
17616 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
17617  global FFTbandwidth # The FFT bandwidth
17618  global FFTwindow # Which FFT window number is selected
17619  global FFTwindowname # The name of the FFT window function
17620  global FFTwindowshape # The window shape
17621  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
17622  global SMPfft # Number of FFT samples
17623  global LastWindow, LastSMPfft
17624 
17625  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
17626  # recalculate window only if something changed
17627  return
17628  # FFTname and FFTbandwidth in milliHz
17629  FFTwindowname = "No such window"
17630  FFTbw = 0
17631 
17632  if FFTwindow.get() == 0:
17633  FFTwindowname = " Rectangular (no) window (B=1) "
17634  FFTbw = 1.0
17635 
17636  if FFTwindow.get() == 1:
17637  FFTwindowname = " Cosine window (B=1.24) "
17638  FFTbw = 1.24
17639 
17640  if FFTwindow.get() == 2:
17641  FFTwindowname = " Triangular window (B=1.33) "
17642  FFTbw = 1.33
17643 
17644  if FFTwindow.get() == 3:
17645  FFTwindowname = " Hann window (B=1.5) "
17646  FFTbw = 1.5
17647 
17648  if FFTwindow.get() == 4:
17649  FFTwindowname = " Blackman window (B=1.73) "
17650  FFTbw = 1.73
17651 
17652  if FFTwindow.get() == 5:
17653  FFTwindowname = " Nuttall window (B=2.02) "
17654  FFTbw = 2.02
17655 
17656  if FFTwindow.get() == 6:
17657  FFTwindowname = " Flat top window (B=3.77) "
17658  FFTbw = 3.77
17659 
17660  if FFTwindow.get() == 7:
17661  FFTwindowname = FFTUserWindowString
17662  FFTbw = 0.0
17663  try:
17664  FFTwindowshape = eval(FFTUserWindowString)
17665  except:
17666  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
17667  print( "Filling FFT window with Ones")
17668  elif FFTwindow.get() == 8: # window shape array read from csv file
17669  FFTwindowname = "Window Shape From file"
17670  FFTbw = 0.0
17671  else:
17672  FFTbandwidth = int(FFTbw * (SAMPLErate/2.0) / float(SMPfft))
17673  # Calculate the shape
17674  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
17675  n = 0
17676  while n < SMPfft:
17677  # Cosine window function - medium-dynamic range B=1.24
17678  if FFTwindow.get() == 1:
17679  w = math.sin(math.pi * n / (SMPfft - 1))
17680  FFTwindowshape[n] = w * 1.571
17681  # Triangular non-zero endpoints - medium-dynamic range B=1.33
17682  if FFTwindow.get() == 2:
17683  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
17684  FFTwindowshape[n] = w * 2.0
17685  # Hann window function - medium-dynamic range B=1.5
17686  if FFTwindow.get() == 3:
17687  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
17688  FFTwindowshape[n] = w * 2.000
17689  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
17690  if FFTwindow.get() == 4:
17691  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
17692  FFTwindowshape[n] = w * 2.381
17693  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
17694  if FFTwindow.get() == 5:
17695  w = 0.355768 - 0.487396 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.144232 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.012604 * math.cos(6 * math.pi * n / (SMPfft - 1))
17696  FFTwindowshape[n] = w * 2.811
17697  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
17698  if FFTwindow.get() == 6:
17699  w = 1.0 - 1.93 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 1.29 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.388 * math.cos(6 * math.pi * n / (SMPfft - 1)) + 0.032 * math.cos(8 * math.pi * n / (SMPfft - 1))
17700  FFTwindowshape[n] = w * 1.000
17701  n = n + 1
17702  LastWindow = FFTwindow.get()
17703  LastSMPfft = SMPfft
17704 
17706  global FFTUserWindowString, freqwindow
17707 
17708  TempString = FFTUserWindowString
17709  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
17710  if (FFTUserWindowString == None): # If Cancel pressed, then None
17711  FFTUserWindowString = TempString
17712 
17714  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
17715 
17716  # Read values from CVS file
17717  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
17718  try:
17719  CSVFile = open(filename)
17720  csv_f = csv.reader(CSVFile)
17721  FFTwindowshape = []
17722  for row in csv_f:
17723  try:
17724  FFTwindowshape.append(float(row[0]))
17725  except:
17726  print( 'skipping non-numeric row')
17727  FFTwindowshape = numpy.array(FFTwindowshape)
17728  CSVFile.close()
17729  SMPfft = len(FFTwindowshape)
17730  LastSMPfft = SMPfft
17731  LastWindow = FFTwindow.get()
17732  print( SMPfft)
17733  except:
17734  showwarning("WARNING","No such file found or wrong format!")
17735 #
17737  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
17738 
17739  FCursor = event.x
17740  dBCursor = event.y
17741  if RUNstatus.get() == 0:
17743  Freqca.bind('<MouseWheel>', onCanvasFreqClickScroll)
17744  Freqca.bind("<Button-4>", onCanvasFreqClickScroll)# with Linux OS
17745  Freqca.bind("<Button-5>", onCanvasFreqClickScroll)
17746 #
17748  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
17749 
17750  if event.widget == Freqca:
17751  ShiftKeyDwn = event.state & 1
17752  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
17753  # respond to Linux or Windows wheel event
17754  if event.num == 5 or event.delta == -120:
17755  FCursor -= 1
17756  if event.num == 4 or event.delta == 120:
17757  FCursor += 1
17758  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
17759  # respond to Linux or Windows wheel event
17760  if event.num == 5 or event.delta == -120:
17761  dBCursor += 1
17762  if event.num == 4 or event.delta == 120:
17763  dBCursor -= 1
17764  if RUNstatus.get() == 0:
17766 #
17768  global X0LF # Left top X value
17769  global Y0TF # Left top Y value
17770  global GRWF # Screenwidth
17771  global GRHF # Screenheight
17772  global FontSize
17773  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
17774  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
17775  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
17776  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
17777  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17778 
17779  if (RUNstatus.get() == 0):
17780  MarkerFreqNum = MarkerFreqNum + 1
17781  COLORmarker = COLORgrid
17782  if ShowC1_VdB.get() == 1:
17783  COLORmarker = COLORtrace1
17784  elif ShowC2_VdB.get() == 1:
17785  COLORmarker = COLORtrace2
17786  try:
17787  StartFrequency = float(StartFreqEntry.get())
17788  except:
17789  StartFreqEntry.delete(0,"end")
17790  StartFreqEntry.insert(0,100)
17791  StartFrequency = 100
17792  try:
17793  StopFrequency = float(StopFreqEntry.get())
17794  except:
17795  StopFreqEntry.delete(0,"end")
17796  StopFreqEntry.insert(0,100)
17797  StopFrequency = 100
17798  # draw X at marker point and number
17799  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
17800  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
17801  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
17802  # Vertical conversion factors (level dBs) and border limits
17803  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17804  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
17805  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
17806  YVc = float(Y0TF) + YVconv * SAvertmax
17807  Yphconv = float(GRHF) / 360
17808  Yp = float(Y0TF) + Yphconv + 180
17809  # Horizontal conversion factors (frequency Hz) and border limits
17810  if HScale.get() == 1:
17811  LogFStop = math.log10(StopFrequency)
17812  try:
17813  LogFStart = math.log10(StartFrequency)
17814  except:
17815  LogFStart = 0.0
17816  LogFpixel = (LogFStop - LogFStart) / GRWF
17817  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
17818  else:
17819  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17820  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
17821  #
17822  try:
17823  LogVStop = math.log10(SAvertmax)
17824  except:
17825  LogVStop = 0.0
17826  try:
17827  LogVStart = math.log10(SAvertmin)
17828  except:
17829  LogVStart = -10
17830  LogVpixel = (LogVStop - LogVStart) / GRHF
17831  #
17832  XFString = ' {0:.2f} '.format(xfreq)
17833  if SAVScale.get() == 0:
17834  yvdB = ((Yc-event.y)/Yconv)
17835  VdBString = ' {0:.3f} '.format(yvdB)
17836  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
17837  else:
17838  if SAVScale.get() == 1:
17839  yvdB = ((YVc-event.y)/YVconv)
17840  VdBString = ' {0:.3f} '.format(yvdB)
17841  else:
17842  Vlog = ((YVc - event.y) * LogVpixel) + LogVStart
17843  yvdB = 10**Vlog
17844  VdBString = ' {:.2e} '.format(yvdB)
17845  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " Vrms"
17846 
17847  if MarkerFreqNum > 1:
17848  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17849  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
17850  if SAVScale.get() == 0:
17851  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17852  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
17853  else:
17854  if SAVScale.get() == 1:
17855  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17856  else:
17857  DeltaV = ' {0:.2e} '.format(yvdB-PrevdBV)
17858  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " Vrms"
17859  x = X0LF + 5
17860  y = Y0TF + 3 + (MarkerFreqNum*10)
17861  Justify = 'w'
17862  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
17863  x = X0LF + GRWF - 5
17864  y = Y0TF + 3 + (MarkerFreqNum*10)
17865  Justify = 'e'
17866  if MarkerLoc == 'LL' or MarkerLoc == 'll':
17867  x = X0LF + 5
17868  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
17869  Justify = 'w'
17870  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
17871  x = X0LF + GRWF - 5
17872  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
17873  Justify = 'e'
17874  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
17875  PrevdBV = yvdB
17876  PrevF = xfreq
17877 #
17878 def onCanvasSAOne(event):
17879  global ShowC1_VdB
17880  if ShowC1_VdB.get() == 0:
17881  ShowC1_VdB.set(1)
17882  else:
17883  ShowC1_VdB.set(0)
17884 #
17885 def onCanvasSATwo(event):
17886  global ShowC2_VdB
17887  if ShowC2_VdB.get() == 0:
17888  ShowC2_VdB.set(1)
17889  else:
17890  ShowC2_VdB.set(0)
17891 #
17892 def onCanvasSAThree(event):
17893  global ShowC1_P
17894  if ShowC1_P.get() == 0:
17895  ShowC1_P.set(1)
17896  else:
17897  ShowC1_P.set(0)
17898 #
17899 def onCanvasSAFour(event):
17900  global ShowC2_P
17901  if ShowC2_P.get() == 0:
17902  ShowC2_P.set(1)
17903  else:
17904  ShowC2_P.set(0)
17905 #
17906 def onCanvasSAFive(event):
17907  global ShowMarker
17908  if ShowMarker.get() == 0:
17909  ShowMarker.set(1)
17910  else:
17911  ShowMarker.set(0)
17912 #
17913 def onCanvasSASix(event):
17914  global ShowRA_VdB
17915  if ShowRA_VdB.get() == 0:
17916  ShowRA_VdB.set(1)
17917  else:
17918  ShowRA_VdB.set(0)
17919 #
17920 def onCanvasSASeven(event):
17921  global ShowRB_VdB
17922  if ShowRB_VdB.get() == 0:
17923  ShowRB_VdB.set(1)
17924  else:
17925  ShowRB_VdB.set(0)
17926 #
17927 def onCanvasSAEight(event):
17928  global ShowMathSA
17929  ShowMathSA.set(2)
17930 #
17931 def onCanvasSANine(event):
17932  global ShowMathSA
17933  ShowMathSA.set(1)
17934 #
17935 def onCanvasSAZero(event):
17936  global ShowMathSA
17937  ShowMathSA.set(0)
17938 #
17939 def onCanvasSASnap(event):
17940  BSTOREtraceSA()
17941 #
17942 def onCanvasSANormal(event):
17943  BNormalmode()
17944 #
17945 def onCanvasSAPeak(event):
17946  BPeakholdmode()
17947 
17948 def onCanvasSAReset(event):
17949  BResetFreqAvg()
17950 #
17952  BAveragemode()
17953 #
17954 def onCanvasShowFcur(event):
17955  global ShowFCur
17956  if ShowFCur.get() == 0:
17957  ShowFCur.set(1)
17958  else:
17959  ShowFCur.set(0)
17960 #
17962  global ShowdBCur
17963  if ShowdBCur.get() == 1:
17964  ShowdBCur.set(0)
17965  else:
17966  ShowdBCur.set(1)
17967 #
17968 def onCanvasShowPcur(event):
17969  global ShowdBCur
17970  if ShowdBCur.get() == 2:
17971  ShowdBCur.set(0)
17972  else:
17973  ShowdBCur.set(2)
17974 #
17976  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
17977 
17978  BPCursor = event.x
17979  BdBCursor = event.y
17980  if RUNstatus.get() == 0:
17982  #Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
17983  Bodeca.bind('<MouseWheel>', onCanvasBodeClickScroll)
17984  Bodeca.bind("<Button-4>", onCanvasBodeClickScroll)# with Linux OS
17985  Bodeca.bind("<Button-5>", onCanvasBodeClickScroll)
17986 #
17988  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
17989 
17990  # print event.state
17991  shift_key = event.state & 1
17992  if ShowBPCur.get() > 0 and shift_key == 0:
17993  # respond to Linux or Windows wheel event
17994  if event.num == 5 or event.delta == -120:
17995  BPCursor -= 1
17996  if event.num == 4 or event.delta == 120:
17997  BPCursor += 1
17998  elif ShowBdBCur.get() > 0 or shift_key == 1:
17999  # respond to Linux or Windows wheel event
18000  if event.num == 5 or event.delta == -120:
18001  BdBCursor += 1
18002  if event.num == 4 or event.delta == 120:
18003  BdBCursor -= 1
18004  if RUNstatus.get() == 0:
18006 #
18008  global X0LBP # Left top X value
18009  global Y0TBP # Left top Y value
18010  global GRWBP # Screenwidth
18011  global GRHBP # Screenheight
18012  global FontSize
18013  global Bodeca, MarkerLoc, SAMPLErate
18014  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
18015  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
18016  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
18017 
18018  if (RUNstatus.get() == 0):
18019  MarkerFreqNum = MarkerFreqNum + 1
18020  COLORmarker = COLORtrace6 # COLORgrid
18021  if ShowCA_VdB.get() == 1:
18022  COLORmarker = COLORtrace1
18023  elif ShowCB_VdB.get() == 1:
18024  COLORmarker = COLORtrace2
18025  try:
18026  EndFreq = float(StopBodeEntry.get())
18027  except:
18028  StopBodeEntry.delete(0,"end")
18029  StopBodeEntry.insert(0,10000)
18030  EndFreq = 10000
18031  try:
18032  BeginFreq = float(StartBodeEntry.get())
18033  except:
18034  StartBodeEntry.delete(0,"end")
18035  StartBodeEntry.insert(0,100)
18036  BeginFreq = 100
18037  # draw X at marker point and number
18038  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
18039  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
18040  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
18041  # Vertical conversion factors (level dBs) and border limits
18042  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18043  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
18044  Yphconv = float(GRHBP) / 360
18045  Yp = float(Y0TBP) + Yphconv + 180
18046  x1 = X0LBP + 14
18047  x2 = x1 + GRWBP
18048  # Horizontal conversion factors (frequency Hz) and border limits
18049  if HScaleBP.get() == 1:
18050  LogFStop = math.log10(EndFreq)
18051  try:
18052  LogFStart = math.log10(BeginFreq)
18053  except:
18054  LogFStart = 0.0
18055  LogFpixel = (LogFStop - LogFStart) / GRWBP
18056  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
18057  else:
18058  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
18059  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
18060 
18061  yvdB = ((Yc-event.y)/Yconv)
18062  VdBString = ' {0:.1f} '.format(yvdB)
18063  XFString = ' {0:.2f} '.format(xfreq)
18064  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18065  if MarkerFreqNum > 1:
18066  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18067  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18068  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18069  x = x1 + 5
18070  y = Y0TBP + 3 + (MarkerFreqNum*10)
18071  Justify = 'w'
18072  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
18073  x = x2 - 5
18074  y = Y0TBP + 3 + (MarkerFreqNum*10)
18075  Justify = 'e'
18076  if MarkerLoc == 'LL' or MarkerLoc == 'll':
18077  x = x1 + 5
18078  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18079  Justify = 'w'
18080  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
18081  x = x2 - 5
18082  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18083  Justify = 'e'
18084  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
18085  PrevdBV = yvdB
18086  PrevF = xfreq
18087 #
18088 def onCanvasBdOne(event):
18089  global ShowCA_VdB
18090  if ShowCA_VdB.get() == 0:
18091  ShowCA_VdB.set(1)
18092  else:
18093  ShowCA_VdB.set(0)
18094 #
18095 def onCanvasBdTwo(event):
18096  global ShowCB_VdB
18097  if ShowCB_VdB.get() == 0:
18098  ShowCB_VdB.set(1)
18099  else:
18100  ShowCB_VdB.set(0)
18101 #
18102 def onCanvasBdThree(event):
18103  global ShowCA_P
18104  if ShowCA_P.get() == 0:
18105  ShowCA_P.set(1)
18106  else:
18107  ShowCA_P.set(0)
18108 #
18109 def onCanvasBdFour(event):
18110  global ShowCB_P
18111  if ShowCB_P.get() == 0:
18112  ShowCB_P.set(1)
18113  else:
18114  ShowCB_P.set(0)
18115 #
18116 def onCanvasBdFive(event):
18117  global ShowMarkerBP
18118  if ShowMarkerBP.get() == 0:
18119  ShowMarkerBP.set(1)
18120  else:
18121  ShowMarkerBP.set(0)
18122 #
18123 def onCanvasBdSix(event):
18124  global ShowRA_VdB
18125  if ShowRA_VdB.get() == 0:
18126  ShowRA_VdB.set(1)
18127  else:
18128  ShowRA_VdB.set(0)
18129 #
18130 def onCanvasBdSeven(event):
18131  global ShowRB_VdB
18132  if ShowRB_VdB.get() == 0:
18133  ShowRB_VdB.set(1)
18134  else:
18135  ShowRB_VdB.set(0)
18136 #
18137 def onCanvasBdEight(event):
18138  global ShowMathBP
18139  ShowMathBP.set(2)
18140 #
18141 def onCanvasBdNine(event):
18142  global ShowMathBP
18143  ShowMathBP.set(1)
18144 #
18145 def onCanvasBdZero(event):
18146  global ShowMathBP
18147  ShowMathBP.set(0)
18148 #
18149 def onCanvasBdSnap(event):
18150  BSTOREtraceBP()
18151 #
18153  global ShowBPCur
18154  if ShowBPCur.get() == 0:
18155  ShowBPCur.set(1)
18156  else:
18157  ShowBPCur.set(0)
18158 #
18160  global ShowBdBCur
18161  if ShowBdBCur.get() == 1:
18162  ShowBdBCur.set(0)
18163  else:
18164  ShowBdBCur.set(1)
18165 #
18167  global ShowBdBCur
18168  if ShowBdBCur.get() == 2:
18169  ShowBdBCur.set(0)
18170  else:
18171  ShowBdBCur.set(2)
18172 #
18173 def onAWGAscroll(event):
18174  global AWGAShape
18175 
18176  onTextScroll(event)
18177  time.sleep(0.05)
18178  ReMakeAWGwaves()
18179  time.sleep(0.05)
18180 #
18181 def onAWGBscroll(event):
18182  global AWGBShape
18183 
18184  onTextScroll(event)
18185  time.sleep(0.05)
18186  ReMakeAWGwaves()
18187  time.sleep(0.05)
18188 #
18189 def onTextScroll(event): # Use mouse wheel to scroll entry values, august 7
18190  button = event.widget
18191  cursor_position = button.index(INSERT) # get current cursor position
18192  Pos = cursor_position
18193  OldVal = button.get() # get current entry string
18194  OldValfl = float(OldVal) # and its value
18195  NewVal = OldValfl
18196  Len = len(OldVal)
18197  Dot = OldVal.find (".") # find decimal point position
18198  Decimals = Len - Dot - 1
18199  if Dot == -1 : # no point
18200  Decimals = 0
18201  Step = 10**(Len - Pos)
18202  elif Pos <= Dot : # no point left of position
18203  Step = 10**(Dot - Pos)
18204  else:
18205  Step = 10**(Dot - Pos + 1)
18206  # respond to Linux or Windows wheel event
18207  if event.num == 5 or event.delta == -120:
18208  NewVal = OldValfl - Step
18209  if event.num == 4 or event.delta == 120:
18210  NewVal = OldValfl + Step
18211  FormatStr = "{0:." + str(Decimals) + "f}"
18212  NewStr = FormatStr.format(NewVal)
18213  NewDot = NewStr.find (".")
18214  NewPos = Pos + NewDot - Dot
18215  if Decimals == 0 :
18216  NewLen = len(NewStr)
18217  NewPos = Pos + NewLen - Len
18218  button.delete(0, END) # remove old entry
18219  button.insert(0, NewStr) # insert new entry
18220  button.icursor(NewPos) # resets the insertion cursor
18221 #
18222 def onAWGAkey(event):
18223  global AWGAShape
18224 
18225  onTextKey(event)
18226  ReMakeAWGwaves()
18227 #
18228 def onAWGBkey(event):
18229  global AWGBShape
18230 
18231  onTextKey(event)
18232  ReMakeAWGwaves()
18233 #
18234 def onTextKeyAWG(event):
18235  onTextKey(event)
18236  ReMakeAWGwaves()
18237 #
18238 # Use Arriw keys to inc dec entry values
18239 def onTextKey(event):
18240  button = event.widget
18241  cursor_position = button.index(INSERT) # get current cursor position
18242  Pos = cursor_position
18243  OldVal = button.get() # get current entry string
18244  OldValfl = float(OldVal) # and its value
18245  Len = len(OldVal)
18246  Dot = OldVal.find (".") # find decimal point position
18247  Decimals = Len - Dot - 1
18248  if Dot == -1 : # no point
18249  Decimals = 0
18250  Step = 10**(Len - Pos)
18251  elif Pos <= Dot : # no point left of position
18252  Step = 10**(Dot - Pos)
18253  else:
18254  Step = 10**(Dot - Pos + 1)
18255  if platform.system() == "Windows":
18256  if event.keycode == 38: # increment digit for up arrow key
18257  NewVal = OldValfl + Step
18258  elif event.keycode == 40: # decrement digit for down arrow
18259  NewVal = OldValfl - Step
18260  else:
18261  return
18262  elif platform.system() == "Linux":
18263  if event.keycode == 111: # increment digit for up arrow key
18264  NewVal = OldValfl + Step
18265  elif event.keycode == 116: # decrement digit for down arrow
18266  NewVal = OldValfl - Step
18267  else:
18268  return
18269  elif platform.system() == "Darwin":
18270  if event.keycode == 0x7D: # increment digit for up arrow key
18271  NewVal = OldValfl + Step
18272  elif event.keycode == 0x7E: # decrement digit for down arrow
18273  NewVal = OldValfl - Step
18274  else:
18275  return
18276  else:
18277  return
18278 #
18279  FormatStr = "{0:." + str(Decimals) + "f}"
18280  NewStr = FormatStr.format(NewVal)
18281  NewDot = NewStr.find (".")
18282  NewPos = Pos + NewDot - Dot
18283  if Decimals == 0 :
18284  NewLen = len(NewStr)
18285  NewPos = Pos + NewLen - Len
18286  button.delete(0, END) # remove old entry
18287  button.insert(0, NewStr) # insert new entry
18288  button.icursor(NewPos) # resets the insertion cursor
18289 #
18290 #
18291 def onSpinBoxScroll(event):
18292  spbox = event.widget
18293  if sys.version_info[0] == 3 and sys.version_info[1] > 6: # Spin Boxes do this automatically in Python > 3.6 apparently
18294  return
18295  if event.num == 4 or event.delta > 0: # if event.delta > 0: # increment digit
18296  spbox.invoke('buttonup')
18297  if event.num == 5 or event.delta < 0:
18298  spbox.invoke('buttondown')
18299 #
18300 # ================ Make awg sub window ==========================
18302  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
18303  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
18304  global AWGABurstFlag, AWGBBurstFlag, AWGAShapeLabel, AWGBShapeLabel, AWGShowAdvanced
18305  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
18306  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
18307  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
18308  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
18309  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
18310  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
18311  global ModeAMenu, ShapeAMenu, amp1lab, off1lab, freq1lab, awgaph, awgadel, ModeBMenu, ShapeBMenu
18312  global amp2lab, off2lab, freq2lab, awgbph, awgbdel, bcompa, awgsync
18313  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise, NoiseList
18314 
18315  if AWGScreenStatus.get() == 0:
18316  AWGScreenStatus.set(1)
18317 
18318  awgwindow = Toplevel()
18319  awgwindow.title("AWG Controls " + SWRev + RevDate)
18320  awgwindow.resizable(FALSE,FALSE)
18321  awgwindow.geometry('+0+100')
18322  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
18323  #
18324  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
18325  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
18326  #
18327  if AwgLayout == "Horz":
18328  frame2.pack(side=LEFT, expand=1, fill=X)
18329  frame3.pack(side=LEFT, expand=1, fill=X)
18330  else:
18331  frame2.pack(side=TOP, expand=1, fill=Y)
18332  frame3.pack(side=TOP, expand=1, fill=Y)
18333  # now AWG A
18334  # AWG enable sub frame
18335  awg1eb = Frame( frame2 )
18336  awg1eb.pack(side=TOP)
18337  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
18338  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
18339  ModeAMenu["menu"] = ModeAMenu.menu
18340  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
18341  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
18342  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
18343  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
18344  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
18345  ModeAMenu.menu.add_separator()
18346  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
18347  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
18348  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
18349  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
18350  ModeAMenu.pack(side=LEFT, anchor=W)
18351  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
18352  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
18353  ShapeAMenu["menu"] = ShapeAMenu.menu
18354  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
18355  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
18356  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
18357  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
18358  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
18359  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
18360  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
18361  if AWGShowAdvanced.get() > 0:
18362  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
18363  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
18364  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
18365  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
18366  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
18367  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
18368  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
18369  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
18370  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
18371  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
18372  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
18373  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
18374  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
18375  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
18376  else:
18377  ShapeAMenu.menu.add_separator()
18378  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
18379  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
18380  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
18381  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
18382  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
18383  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
18384  ShapeAMenu.pack(side=LEFT, anchor=W)
18385  #
18386  AWGAModeLabel = Label(frame2, text="AWG A Mode")
18387  AWGAModeLabel.pack(side=TOP)
18388  AWGAShapeLabel = Label(frame2, text="AWG A Shape")
18389  AWGAShapeLabel.pack(side=TOP)
18390  #
18391  awg1ampl = Frame( frame2 )
18392  awg1ampl.pack(side=TOP)
18393  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
18394  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
18395  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
18396  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18397  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
18398  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
18399  AWGAAmplEntry.pack(side=LEFT, anchor=W)
18400  AWGAAmplEntry.delete(0,"end")
18401  AWGAAmplEntry.insert(0,0.0)
18402  amp1lab = Label(awg1ampl) #, text="Min Ch A")
18403  amp1lab.pack(side=LEFT, anchor=W)
18404  #
18405  awg1off = Frame( frame2 )
18406  awg1off.pack(side=TOP)
18407  AWGAOffsetEntry = Entry(awg1off, width=5, cursor='double_arrow')
18408  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
18409  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
18410  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18411  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
18412  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
18413  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
18414  AWGAOffsetEntry.delete(0,"end")
18415  AWGAOffsetEntry.insert(0,0.0)
18416  off1lab = Label(awg1off) #, text="Max Ch A")
18417  off1lab.pack(side=LEFT, anchor=W)
18418  if AWG_Amp_Mode.get() == 0:
18419  amp1lab.config(text = "Min Ch A" ) # change displayed value
18420  off1lab.config(text = "Max Ch A" ) # change displayed value
18421  else:
18422  amp1lab.config(text = "Amp Ch A" )
18423  off1lab.config(text = "Off Ch A" )
18424  # AWG Frequency sub frame
18425  awg1freq = Frame( frame2 )
18426  awg1freq.pack(side=TOP)
18427  AWGAFreqEntry = Entry(awg1freq, width=7, cursor='double_arrow')
18428  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
18429  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
18430  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18431  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
18432  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
18433  AWGAFreqEntry.pack(side=LEFT, anchor=W)
18434  AWGAFreqEntry.delete(0,"end")
18435  AWGAFreqEntry.insert(0,100.0)
18436  freq1lab = Label(awg1freq, text="Freq Ch A")
18437  freq1lab.pack(side=LEFT, anchor=W)
18438  # AWG Phase or delay select sub frame
18439  # AWG Phase entry sub frame
18440  awg1phase = Frame( frame2 )
18441  awg1phase.pack(side=TOP)
18442  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
18443  awgaph.pack(side=LEFT, anchor=W)
18444  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
18445  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
18446  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
18447  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18448  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
18449  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
18450  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
18451  AWGAPhaseEntry.delete(0,"end")
18452  AWGAPhaseEntry.insert(0,0)
18453  phasealab = Label(awg1phase, text="Deg")
18454  phasealab.pack(side=LEFT, anchor=W)
18455  # AWG duty cycle frame
18456  awg1dc = Frame( frame2 )
18457  awg1dc.pack(side=TOP)
18458  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
18459  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
18460  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
18461  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18462  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
18463  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
18464  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
18465  AWGADutyCycleEntry.delete(0,"end")
18466  AWGADutyCycleEntry.insert(0,50)
18467  duty1lab = Label(awg1dc, text="%")
18468  duty1lab.pack(side=LEFT, anchor=W)
18469  #
18470  AWGALength = Label(frame2, text="Length")
18471  AWGALength.pack(side=TOP)
18472  # Noise Controls
18473  anoise = Frame( frame2 )
18474  anoise.pack(side=TOP)
18475  AWGANoise = Label(anoise, text="Noise")
18476  AWGANoise.pack(side=LEFT, anchor=W)
18477  AWGAsbnoise = Spinbox(anoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
18478  AWGAsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
18479  AWGAsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18480  AWGAsbnoise.bind("<Button-5>", onSpinBoxScroll)
18481  AWGAsbnoise.pack(side=LEFT, anchor=W)
18482  AWGANoiseEntry = Entry(anoise, width=5, cursor='double_arrow')
18483  AWGANoiseEntry.bind("<Return>", UpdateAwgContRet)
18484  AWGANoiseEntry.bind('<MouseWheel>', onAWGAscroll)
18485  AWGANoiseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18486  AWGANoiseEntry.bind("<Button-5>", onAWGAscroll)
18487  AWGANoiseEntry.bind('<Key>', onTextKeyAWG)
18488  AWGANoiseEntry.pack(side=LEFT, anchor=W)
18489  AWGANoiseEntry.delete(0,"end")
18490  AWGANoiseEntry.insert(0,0.0)
18491  #
18492  if FWRevOne > 2.16:
18493  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
18494  awg2x1.pack(side=TOP)
18495  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
18496  awg2x2.pack(side=TOP)
18497  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
18498  awg2x3.pack(side=TOP)
18499  else:
18500  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
18501  awgsync.pack(side=TOP)
18502  # now AWG B
18503  # AWG enable sub frame
18504  awg2eb = Frame( frame3 )
18505  awg2eb.pack(side=TOP)
18506  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
18507  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
18508  ModeBMenu["menu"] = ModeBMenu.menu
18509  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
18510  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
18511  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
18512  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
18513  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
18514  ModeBMenu.menu.add_separator()
18515  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
18516  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
18517  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
18518  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
18519  ModeBMenu.pack(side=LEFT, anchor=W)
18520  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
18521  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
18522  ShapeBMenu["menu"] = ShapeBMenu.menu
18523  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
18524  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
18525  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
18526  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
18527  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
18528  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
18529  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
18530  if AWGShowAdvanced.get() > 0:
18531  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
18532  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
18533  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
18534  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
18535  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
18536  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
18537  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
18538  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
18539  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
18540  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
18541  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
18542  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
18543  else:
18544  ShapeBMenu.menu.add_separator()
18545  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
18546  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
18547  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
18548  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
18549  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
18550  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
18551  ShapeBMenu.pack(side=LEFT, anchor=W)
18552  #
18553  AWGBModeLabel = Label(frame3, text="AWG B Mode")
18554  AWGBModeLabel.pack(side=TOP)
18555  AWGBShapeLabel = Label(frame3, text="AWG B Shape")
18556  AWGBShapeLabel.pack(side=TOP)
18557  #
18558  awg2ampl = Frame( frame3 )
18559  awg2ampl.pack(side=TOP)
18560  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
18561  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
18562  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
18563  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18564  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
18565  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
18566  AWGBAmplEntry.pack(side=LEFT, anchor=W)
18567  AWGBAmplEntry.delete(0,"end")
18568  AWGBAmplEntry.insert(0,0.0)
18569  amp2lab = Label(awg2ampl) #, text="Min Ch B")
18570  amp2lab.pack(side=LEFT, anchor=W)
18571  #
18572  awg2off = Frame( frame3 )
18573  awg2off.pack(side=TOP)
18574  AWGBOffsetEntry = Entry(awg2off, width=5, cursor='double_arrow')
18575  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
18576  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
18577  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18578  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
18579  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
18580  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
18581  AWGBOffsetEntry.delete(0,"end")
18582  AWGBOffsetEntry.insert(0,0.0)
18583  off2lab = Label(awg2off) #, text="Max Ch B")
18584  off2lab.pack(side=LEFT, anchor=W)
18585  if AWG_Amp_Mode.get() == 0:
18586  amp2lab.config(text = "Min Ch B" ) # change displayed value
18587  off2lab.config(text = "Max Ch B" ) # change displayed value
18588  else:
18589  amp2lab.config(text = "Amp Ch B" )
18590  off2lab.config(text = "Off Ch B" )
18591  # AWG Frequency sub frame
18592  awg2freq = Frame( frame3 )
18593  awg2freq.pack(side=TOP)
18594  AWGBFreqEntry = Entry(awg2freq, width=7, cursor='double_arrow')
18595  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
18596  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
18597  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18598  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
18599  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
18600  AWGBFreqEntry.pack(side=LEFT, anchor=W)
18601  AWGBFreqEntry.delete(0,"end")
18602  AWGBFreqEntry.insert(0,100.0)
18603  freq2lab = Label(awg2freq, text="Freq Ch B")
18604  freq2lab.pack(side=LEFT, anchor=W)
18605  # AWG Phase or delay select sub frame
18606  # AWG Phase sub frame
18607  awg2phase = Frame( frame3 )
18608  awg2phase.pack(side=TOP)
18609  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
18610  awgbph.pack(side=LEFT, anchor=W)
18611  AWGBPhaseEntry = Entry(awg2phase, width=4, cursor='double_arrow')
18612  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
18613  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
18614  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18615  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
18616  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
18617  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
18618  AWGBPhaseEntry.delete(0,"end")
18619  AWGBPhaseEntry.insert(0,0)
18620  phaseblab = Label(awg2phase, text="Deg")
18621  phaseblab.pack(side=LEFT, anchor=W)
18622  # AWG duty cycle frame
18623  awg2dc = Frame( frame3 )
18624  awg2dc.pack(side=TOP)
18625  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
18626  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
18627  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
18628  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18629  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
18630  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
18631  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
18632  AWGBDutyCycleEntry.delete(0,"end")
18633  AWGBDutyCycleEntry.insert(0,50)
18634  duty2lab = Label(awg2dc, text="%")
18635  duty2lab.pack(side=LEFT, anchor=W)
18636  #
18637  AWGBLength = Label(frame3, text="Length")
18638  AWGBLength.pack(side=TOP)
18639  # Noise Controls
18640  bnoise = Frame( frame3 )
18641  bnoise.pack(side=TOP)
18642  AWGBNoise = Label(bnoise, text="Noise")
18643  AWGBNoise.pack(side=LEFT, anchor=W)
18644  AWGBsbnoise = Spinbox(bnoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
18645  AWGBsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
18646  AWGBsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18647  AWGBsbnoise.bind("<Button-5>", onSpinBoxScroll)
18648  AWGBsbnoise.pack(side=LEFT, anchor=W)
18649  AWGBNoiseEntry = Entry(bnoise, width=5, cursor='double_arrow')
18650  AWGBNoiseEntry.bind("<Return>", UpdateAwgContRet)
18651  AWGBNoiseEntry.bind('<MouseWheel>', onAWGBscroll)
18652  AWGBNoiseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18653  AWGBNoiseEntry.bind("<Button-5>", onAWGBscroll)
18654  AWGBNoiseEntry.bind('<Key>', onTextKeyAWG)
18655  AWGBNoiseEntry.pack(side=LEFT, anchor=W)
18656  AWGBNoiseEntry.delete(0,"end")
18657  AWGBNoiseEntry.insert(0,0.0)
18658  #
18659  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
18660  bcompa.pack(side=TOP)
18661  if FWRevOne > 2.16:
18662  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
18663  awgsync.pack(side=TOP)
18664  #
18665  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
18666  dismissbutton.pack(side=TOP)
18667  if ShowBallonHelp > 0:
18668  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
18669  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
18670  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
18671  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
18672  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
18673  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
18674  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
18675  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
18676  else:
18677  awgwindow.deiconify()
18678 #
18679 def BAWG2X():
18680  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
18681 
18682  ReMakeAWGwaves()
18683  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
18684  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
18685  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
18686  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
18687  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
18688  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
18689  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
18690  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
18691  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
18692  BisCompA.set(0)
18693  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
18694  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
18695  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
18696  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
18697  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
18698  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
18699  BisCompA.set(0)
18700 #
18702  global awgwindow, AWGScreenStatus
18703 
18704  # AWGScreenStatus.set(0)
18705  awgwindow.iconify()
18706 #
18707 # ===== Channel B Mux Mode sub Window =======
18709  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
18710  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
18711  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
18712  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
18713  global CHB_cba, CHB_cbb, CHB_cbc, CHB_cbd
18714  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev, BorderSize
18715  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg
18716  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
18717  global ChopMuxMode, ChopTrig, DualMuxMode, ShowBallonHelp
18718 
18719  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
18720  MuxScreenStatus.set(1)
18721  #
18722  BAWGEnab() # update AWG settings
18723  #
18724  muxwindow = Toplevel()
18725  muxwindow.title("External Mux " + SWRev + RevDate)
18726  muxwindow.resizable(FALSE,FALSE)
18727  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
18728  #
18729  frameM = LabelFrame(muxwindow, text="External Analog Mux", style="A10.TLabelframe") #
18730  frameM.pack(side=LEFT, expand=1, fill=X)
18731  #
18732  # Voltage channel CHB-A
18733  frameA = Frame(frameM)
18734  frameA.pack(side=TOP)
18735  CHB_cba = Checkbutton(frameA, text='CB-A', style="Strace2.TCheckbutton", variable=Show_CBA, command=UpdateTimeTrace)
18736  CHB_cba.pack(side=LEFT, anchor=W)
18737  CHB_Asb = Spinbox(frameA, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18738  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
18739  CHB_Asb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18740  CHB_Asb.bind("<Button-5>", onSpinBoxScroll)
18741  CHB_Asb.pack(side=LEFT)
18742  CHB_Asb.delete(0,"end")
18743  CHB_Asb.insert(0,0.5)
18744  #
18745  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
18746  CHB_Alab.pack(side=LEFT)
18747  CHB_APosEntry = Entry(frameA, width=5, cursor='double_arrow')
18748  CHB_APosEntry.bind('<Return>', onTextKey)
18749  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
18750  CHB_APosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18751  CHB_APosEntry.bind("<Button-5>", onTextScroll)
18752  CHB_APosEntry.bind('<Key>', onTextKey)
18753  CHB_APosEntry.pack(side=LEFT)
18754  CHB_APosEntry.delete(0,"end")
18755  CHB_APosEntry.insert(0,2.5)
18756  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
18757  CHB_Aofflab.pack(side=LEFT)
18758  # Voltage channel CHB-B
18759  frameB = Frame(frameM)
18760  frameB.pack(side=TOP)
18761  CHB_cbb = Checkbutton(frameB, text='CB-B', style="Strace6.TCheckbutton", variable=Show_CBB, command=UpdateTimeTrace)
18762  CHB_cbb.pack(side=LEFT, anchor=W)
18763  CHB_Bsb = Spinbox(frameB, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18764  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
18765  CHB_Bsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18766  CHB_Bsb.bind("<Button-5>", onSpinBoxScroll)
18767  CHB_Bsb.pack(side=LEFT)
18768  CHB_Bsb.delete(0,"end")
18769  CHB_Bsb.insert(0,0.5)
18770  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
18771  CHB_Blab.pack(side=LEFT)
18772  CHB_BPosEntry = Entry(frameB, width=5, cursor='double_arrow')
18773  CHB_BPosEntry.bind('<Return>', onTextKey)
18774  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
18775  CHB_BPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18776  CHB_BPosEntry.bind("<Button-5>", onTextScroll)
18777  CHB_BPosEntry.bind('<Key>', onTextKey)
18778  CHB_BPosEntry.pack(side=LEFT)
18779  CHB_BPosEntry.delete(0,"end")
18780  CHB_BPosEntry.insert(0,2.5)
18781  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
18782  CHB_Bofflab.pack(side=LEFT)
18783  # Voltage channel B-C
18784  frameC = Frame(frameM)
18785  frameC.pack(side=TOP)
18786  CHB_cbc = Checkbutton(frameC, text='CB-C', style="Strace7.TCheckbutton", variable=Show_CBC, command=UpdateTimeTrace)
18787  CHB_cbc.pack(side=LEFT, anchor=W)
18788  CHB_Csb = Spinbox(frameC, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18789  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
18790  CHB_Csb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18791  CHB_Csb.bind("<Button-5>", onSpinBoxScroll)
18792  CHB_Csb.pack(side=LEFT)
18793  CHB_Csb.delete(0,"end")
18794  CHB_Csb.insert(0,0.5)
18795  #
18796  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
18797  CHB_Clab.pack(side=LEFT)
18798  CHB_CPosEntry = Entry(frameC, width=5, cursor='double_arrow')
18799  CHB_CPosEntry.bind('<Return>', onTextKey)
18800  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
18801  CHB_CPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18802  CHB_CPosEntry.bind("<Button-5>", onTextScroll)
18803  CHB_CPosEntry.bind('<Key>', onTextKey)
18804  CHB_CPosEntry.pack(side=LEFT)
18805  CHB_CPosEntry.delete(0,"end")
18806  CHB_CPosEntry.insert(0,2.5)
18807  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
18808  CHB_Cofflab.pack(side=LEFT)
18809  # Voltage channel B-D
18810  frameD = Frame(frameM)
18811  frameD.pack(side=TOP)
18812  CHB_cbd = Checkbutton(frameD, text='CB-D', style="Strace4.TCheckbutton", variable=Show_CBD, command=UpdateTimeTrace)
18813  CHB_cbd.pack(side=LEFT, anchor=W)
18814  CHB_Dsb = Spinbox(frameD, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18815  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
18816  CHB_Dsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18817  CHB_Dsb.bind("<Button-5>", onSpinBoxScroll)
18818  CHB_Dsb.pack(side=LEFT)
18819  CHB_Dsb.delete(0,"end")
18820  CHB_Dsb.insert(0,0.5)
18821  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
18822  CHB_Dlab.pack(side=LEFT)
18823  CHB_DPosEntry = Entry(frameD, width=5, cursor='double_arrow')
18824  CHB_DPosEntry.bind('<Return>', onTextKey)
18825  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
18826  CHB_DPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18827  CHB_DPosEntry.bind("<Button-5>", onTextScroll)
18828  CHB_DPosEntry.bind('<Key>', onTextKey)
18829  CHB_DPosEntry.pack(side=LEFT)
18830  CHB_DPosEntry.delete(0,"end")
18831  CHB_DPosEntry.insert(0,2.5)
18832  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
18833  CHB_Dofflab.pack(side=LEFT)
18834  #
18835  frameR = Frame(frameM)
18836  frameR.pack(side=TOP)
18837  RefTraceMenu = Menubutton(frameR, text="Reference Traces", width=17, style="W17.TButton")
18838  RefTraceMenu.menu = Menu(RefTraceMenu, tearoff = 0 )
18839  RefTraceMenu["menu"] = RefTraceMenu.menu
18840  RefTraceMenu.menu.add_command(label="-Take Snap Shot", command=BSnapShot)
18841  RefTraceMenu.menu.add_command(label="-Ref MUX trace-", foreground="blue", command=donothing)
18842  RefTraceMenu.menu.add_checkbutton(label='RMuxA', background=COLORtraceR2, variable=ShowRMA, command=UpdateTimeTrace)
18843  RefTraceMenu.menu.add_checkbutton(label='RMuxB', background=COLORtraceR6, variable=ShowRMB, command=UpdateTimeTrace)
18844  RefTraceMenu.menu.add_checkbutton(label='RMuxC', background=COLORtraceR7, variable=ShowRMC, command=UpdateTimeTrace)
18845  RefTraceMenu.menu.add_checkbutton(label='RMuxD', background=COLORtraceR4, variable=ShowRMD, command=UpdateTimeTrace)
18846  RefTraceMenu.pack(side=LEFT)
18847  #
18848  frameE = Frame(frameM)
18849  frameE.pack(side=TOP)
18850  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
18851  muxenab.pack(side=LEFT)
18852  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
18853  SyncButton.pack(side=LEFT)
18854  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
18855  dismissbutton.pack(side=LEFT)
18856  frameF = Frame(frameM)
18857  frameF.pack(side=TOP)
18858  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
18859  dmx.pack(side=LEFT)
18860  frameCH = Frame(frameM)
18861  frameCH.pack(side=TOP)
18862  altmx = Radiobutton(frameCH, text='Alternate Sweep', variable=ChopMuxMode, value=0, command=SetChopMuxMode)
18863  altmx.pack(side=LEFT)
18864  chopmx = Radiobutton(frameCH, text='Chop Sweep', variable=ChopMuxMode, value=1, command=SetChopMuxMode)
18865  chopmx.pack(side=LEFT)
18866  frameCT = Frame(frameM)
18867  frameCT.pack(side=TOP)
18868  # Chope Mode trigger drop-down
18869  ChopTrigMenu = Menubutton(frameCT, text="Chop Mode Trigger", width=17, style="W17.TButton")
18870  ChopTrigMenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
18871  ChopTrigMenu["menu"] = ChopTrigMenu.menu
18872  ChopTrigMenu.menu.add_command(label="-MUX Chan-", foreground="blue", command=donothing)
18873  ChopTrigMenu.menu.add_radiobutton(label="None", variable=ChopTrig, value=0) #, command=BAWGBModeLabel)
18874  ChopTrigMenu.menu.add_radiobutton(label="Mux A", variable=ChopTrig, value=1) #, command=BAWGBModeLabel)
18875  ChopTrigMenu.menu.add_radiobutton(label="Mux B", variable=ChopTrig, value=2) #, command=BAWGBModeLabel)
18876  ChopTrigMenu.menu.add_radiobutton(label="Mux C", variable=ChopTrig, value=3) #, command=BAWGBModeLabel)
18877  ChopTrigMenu.menu.add_radiobutton(label="Mux D", variable=ChopTrig, value=4) #, command=BAWGBModeLabel)
18878  ChopTrigMenu.pack(side=LEFT)
18879  #
18880  SaveMuxmenu = Menubutton(frameCT, text="Export csv", width=10, style="W17.TButton")
18881  SaveMuxmenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
18882  SaveMuxmenu["menu"] = SaveMuxmenu.menu
18883  SaveMuxmenu.menu.add_command(label="Save Mux traces", command=BSaveMuxData)
18884  SaveMuxmenu.menu.add_command(label="Save single channel", command=BSaveChannelData)
18885  SaveMuxmenu.pack(side=LEFT)
18886  # Gray out main Channel B controls
18887  CHBlab.config(style="SGray.TButton")
18888  CHBofflab.config(style="SGray.TButton")
18889 
18890  #
18891  if ShowBallonHelp > 0:
18892  CHB_Alab_tip = CreateToolTip(CHB_Alab, 'Select CB-A vertical range/position axis to be used for markers and drawn color')
18893  CHB_Blab_tip = CreateToolTip(CHB_Blab, 'Select CB-B vertical range/position axis to be used for markers and drawn color')
18894  CHB_Clab_tip = CreateToolTip(CHB_Clab, 'Select CB-C vertical range/position axis to be used for markers and drawn color')
18895  CHB_Dlab_tip = CreateToolTip(CHB_Dlab, 'Select CB-D vertical range/position axis to be used for markers and drawn color')
18896  CHB_Aofflab_tip = CreateToolTip(CHB_Aofflab, 'Set CB-A position to DC average of signal')
18897  CHB_Bofflab_tip = CreateToolTip(CHB_Bofflab, 'Set CB-B position to DC average of signal')
18898  CHB_Cofflab_tip = CreateToolTip(CHB_Cofflab, 'Set CB-C position to DC average of signal')
18899  CHB_Dofflab_tip = CreateToolTip(CHB_Dofflab, 'Set CB-D position to DC average of signal')
18900  ChopTrigMenu_tip = CreateToolTip(ChopTrigMenu, 'Menu to Select Trigger Source')
18901  RefTraceMenu_tip = CreateToolTip(RefTraceMenu, 'Menu to Select Mux Reference Traces')
18902  SaveMuxmenu_tip = CreateToolTip(SaveMuxmenu, 'Menu to Export Mux Trace Data to .csv file')
18903 #
18905  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
18906  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab, CHB_cbc, CHB_cbd
18907 
18908  if DualMuxMode.get() == 1:
18909  AWGAIOMode.set(1) # force awg A split I/O mode
18910  AWGBIOMode.set(1) # force awg B split I/O mode
18911  ShowC1_V.set(0) # force A voltage trace off
18912  CHB_cbc.config(text="CA-C")
18913  CHB_cbd.config(text="CA-D")
18914  CHB_Clab.config(text="CA-C V/Div")
18915  CHB_Dlab.config(text="CA-D V/Div")
18916  CHB_Cofflab.config(text="CA-C Pos")
18917  CHB_Dofflab.config(text="CA-D Pos")
18918  BAWGEnab() # update AWG settings
18919  # Gray out main Channel A controls
18920  CHAlab.config(style="SGray.TButton")
18921  CHAofflab.config(style="SGray.TButton")
18922  else:
18923  ShowC1_V.set(1) # force A voltage trace on
18924  CHB_cbc.config(text="CB-C")
18925  CHB_cbd.config(text="CB-D")
18926  CHB_Clab.config(text="CB-C V/Div")
18927  CHB_Dlab.config(text="CB-D V/Div")
18928  CHB_Cofflab.config(text="CB-C Pos")
18929  CHB_Dofflab.config(text="CB-D Pos")
18930  # Reset main Channel A control colors
18931  CHAlab.config(style="Rtrace1.TButton")
18932  CHAofflab.config(style="Rtrace1.TButton")
18933 #
18935  global ChopMuxMode, AWGAIOMode, AWGBIOMode, AWGAMode, AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry
18936  global AWGAPhaseEntry, SAMPLErate, ShowC1_V, ShowC2_V, TgInput
18937 
18938  if ChopMuxMode.get() > 0: # set AWG A to a square wave at 25 KHz 0.5 to 4.5 V, mode = SVMI_SPLIT
18939  AWGAIOMode.set(1) # force awg A split I/O mode
18940  AWGAMode.set(0) # force awg A mode to SVMI
18941  BAWGAModeLabel()
18942  AWGAShape.set(4) # force awg A to square shape
18943  AWGAAmplEntry.delete(0,"end")
18944  AWGAAmplEntry.insert(0,0.5) # force awg A Min value to 0.5 V
18945  AWGAOffsetEntry.delete(0,"end")
18946  AWGAOffsetEntry.insert(0,4.5) # force awg A Max value to 4.5 V
18947  AWGAFreqEntry.delete(0,"end")
18948  AWGAFreqEntry.insert(0,SAMPLErate/4) # force awg A Freg value to 25000 (1/4 base sample rate)
18949  AWGAPhaseEntry.delete(0,"end")
18950  AWGAPhaseEntry.insert(0,0) # force awg A Phase value to 0
18951  ReMakeAWGwaves()
18952  AWGBIOMode.set(1) # force awg A split I/O mode
18953  BAWGBModeLabel()
18954  ShowC1_V.set(0) # force A voltage trace off
18955  ShowC2_V.set(0) # force B voltage trace off
18956  TgInput.set(0) # force main Trigger source to none
18957  CHAlab.config(style="SGray.TButton")
18958  CHAofflab.config(style="SGray.TButton")
18959  else:
18960  CHAlab.config(style="Rtrace1.TButton")
18961  CHAofflab.config(style="Rtrace1.TButton")
18962 
18964  global MuxSync, hipulseimg, lowpulseimg, SyncButton
18965 
18966  if MuxSync.get() == 0:
18967  SyncButton.config(image=hipulseimg)
18968  else:
18969  SyncButton.config(image=lowpulseimg)
18970 
18972  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
18973  global ChopTrig, ChopMuxMode, MarkerScale
18974 
18975  MuxScreenStatus.set(0)
18976  awgsync.config(state=NORMAL)
18977  ChopMuxMode.set(0)
18978  ChopTrig.set(0)
18979  MarkerScale.set(0)
18980  # Reset main Channel B control colors
18981  CHBlab.config(style="Rtrace2.TButton")
18982  CHBofflab.config(style="Rtrace2.TButton")
18983  CHAlab.config(style="Rtrace1.TButton")
18984  CHAofflab.config(style="Rtrace1.TButton")
18985  muxwindow.destroy()
18986 #
18987 def BodeCaresize(event):
18988  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
18989 
18990  CANVASwidthBP = event.width - 4
18991  CANVASheightBP = event.height - 4
18992  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
18993  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
18994  UpdateBodeAll()
18995 #
18997  global FStepSync, DevOne
18998 
18999  if FStepSync.get() == 0:
19000  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
19001  elif FStepSync.get() == 1:
19002  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
19003  elif FStepSync.get() == 2:
19004  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
19005 #
19007  global FSweepSync, DevOne
19008 
19009  if FSweepSync.get() == 0:
19010  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
19011  elif FSweepSync.get() == 1:
19012  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
19013  elif FSweepSync.get() == 2:
19014  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
19015 #
19017  global BDSweepFile, FileSweepFreq, FileSweepAmpl
19018 
19019  if BDSweepFile.get() > 0:
19020  # Read values from CVS file
19021  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
19022  try:
19023  CSVFile = open(filename)
19024  csv_f = csv.reader(CSVFile)
19025  FileSweepFreq = []
19026  FileSweepAmpl = []
19027  for row in csv_f:
19028  try:
19029  FileSweepFreq.append(float(row[0]))
19030  FileSweepAmpl.append(float(row[1]))
19031  except:
19032  print( 'skipping non-numeric row')
19033  FileSweepFreq = numpy.array(FileSweepFreq)
19034  FileSweepAmpl = numpy.array(FileSweepAmpl)
19035  MaxAmpl = numpy.amax(FileSweepAmpl)
19036  NormAmpl = MaxAmpl
19037  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
19038  if (s == None): # If Cancel pressed, then None
19039  return()
19040  try: # Error if for example no numeric characters or OK pressed without input (s = "")
19041  v = int(s)
19042  except:
19043  s = "error"
19044 
19045  if s != "error":
19046  NormAmpl = MaxAmpl - v
19047  else:
19048  NormAmpl = MaxAmpl
19049  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
19050  CSVFile.close()
19051  StopBodeEntry.delete(0,"end")
19052  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
19053  StartBodeEntry.delete(0,"end")
19054  StartBodeEntry.insert(0,FileSweepFreq[0])
19055  SweepStepBodeEntry.delete(0,"end")
19056  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
19057  except:
19058  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
19059 #
19060 # ========== Make Bode Plot Window =============
19062  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
19063  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
19064  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
19065  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
19066  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
19067  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
19068  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
19069  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
19070  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
19071  global FrameRefief, BorderSize, LocalLanguage
19072  global sbode_tip, rbode_tip, bd3_tip, bd4_tip, bd5_tip, bd6_tip, bd7_tip, bd8_tip, bodismiss1button_tip
19073  global bstopfreqlab, bstartfreqlab, ImCenlab, BPhCenlab
19074 
19075  if BodeScreenStatus.get() == 0:
19076  BodeScreenStatus.set(1)
19077  BodeDisp.set(1)
19078  BodeCheckBox()
19079  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
19080  CANVASheightBP = GRHBP + 80 # The ode canvas height
19081  CutDC.set(1) # set to remove DC
19082  AWGAMode.set(0) # Set AWG A to SVMI
19083  AWGAShape.set(1) # Set Shape to Sine
19084  AWGBMode.set(2) # Set AWG B to Hi-Z
19085  bodewindow = Toplevel()
19086  bodewindow.title("Bode Plotter " + SWRev + RevDate)
19087  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
19088  frame2bp = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19089  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
19090 
19091  frame2b = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19092  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
19093 
19094  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
19095  Bodeca.bind('<Configure>', BodeCaresize)
19096  Bodeca.bind('<1>', onCanvasBodeLeftClick)
19097  Bodeca.bind('<3>', onCanvasBodeRightClick)
19098  Bodeca.bind("<Up>", onCanvasUpArrow)
19099  Bodeca.bind("<Down>", onCanvasDownArrow)
19100  Bodeca.bind("<Left>", onCanvasLeftArrow)
19101  Bodeca.bind("<Right>", onCanvasRightArrow)
19102  Bodeca.bind("<space>", onCanvasSpaceBar)
19103  Bodeca.bind("1", onCanvasBdOne)
19104  Bodeca.bind("2", onCanvasBdTwo)
19105  Bodeca.bind("3", onCanvasBdThree)
19106  Bodeca.bind("4", onCanvasBdFour)
19107  Bodeca.bind("5", onCanvasBdFive)
19108  Bodeca.bind("6", onCanvasBdSix)
19109  Bodeca.bind("7", onCanvasBdSeven)
19110  Bodeca.bind("8", onCanvasBdEight)
19111  Bodeca.bind("9", onCanvasBdNine)
19112  Bodeca.bind("0", onCanvasBdZero)
19113  Bodeca.bind("f", onCanvasShowBPcur)
19114  Bodeca.bind("d", onCanvasShowBdBcur)
19115  Bodeca.bind("h", onCanvasShowPdBcur)
19116  Bodeca.bind("s", onCanvasBdSnap)
19117  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
19118 
19119  # right side drop down menu buttons
19120  dropmenu = Frame( frame2bp )
19121  dropmenu.pack(side=TOP)
19122  # File menu
19123  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19124  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
19125  BodeFilemenu["menu"] = BodeFilemenu.menu
19126  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
19127  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
19128  BodeFilemenu.menu.add_command(label="Run Script", command=RunScript)
19129  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
19130  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
19131  BodeFilemenu.pack(side=LEFT, anchor=W)
19132  #
19133  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19134  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
19135  BodeOptionmenu["menu"] = BodeOptionmenu.menu
19136  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19137  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
19138  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19139  BodeOptionmenu.menu.add_command(label="Store trace (s)", command=BSTOREtraceBP)
19140  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19141  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19142  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
19143  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
19144  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
19145  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
19146  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
19147  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
19148  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
19149  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
19150  BodeOptionmenu.pack(side=LEFT, anchor=W)
19151  #
19152  RUNframe = Frame( frame2bp )
19153  RUNframe.pack(side=TOP)
19154  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
19155  rbode.pack(side=LEFT)
19156  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
19157  sbode.pack(side=LEFT)
19158  #
19159  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
19160  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
19161  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
19162  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19163  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19164  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19165  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19166  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19167  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19168  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19169  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19170  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19171  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19172  BodeFFTwindmenu.pack(side=TOP)
19173  #
19174  tracemenu = Frame( frame2bp )
19175  tracemenu.pack(side=TOP)
19176  # Curves menu
19177  # Show channels menu
19178  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
19179  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
19180  BodeShowmenu["menu"] = BodeShowmenu.menu
19181  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
19182  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
19183  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
19184  BodeShowmenu.menu.add_checkbutton(label='CA-dBV (1)', variable=ShowCA_VdB, command=UpdateBodeAll)
19185  BodeShowmenu.menu.add_checkbutton(label='CB-dBV (2)', variable=ShowCB_VdB, command=UpdateBodeAll)
19186  BodeShowmenu.menu.add_checkbutton(label='Phase A-B (3)', variable=ShowCA_P, command=UpdateBodeAll)
19187  BodeShowmenu.menu.add_checkbutton(label='Phase B-A (4)', variable=ShowCB_P, command=UpdateBodeAll)
19188  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
19189  BodeShowmenu.menu.add_radiobutton(label='None (0)', variable=ShowMathBP, value=0, command=UpdateBodeAll)
19190  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB (9)', variable=ShowMathBP, value=1, command=UpdateBodeAll)
19191  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB (8)', variable=ShowMathBP, value=2, command=UpdateBodeAll)
19192  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
19193  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
19194  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
19195  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
19196  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
19197  BodeShowmenu.menu.add_separator()
19198  BodeShowmenu.menu.add_checkbutton(label='RA-dBV (6)', variable=ShowCA_RdB, command=UpdateBodeAll)
19199  BodeShowmenu.menu.add_checkbutton(label='RB-dBV (7)', variable=ShowCB_RdB, command=UpdateBodeAll)
19200  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
19201  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
19202  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
19203  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
19204  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
19205  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
19206  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
19207  BodeShowmenu.pack(side=LEFT, anchor=W)
19208  #
19209  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
19210  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
19211  BodeMarkmenu["menu"] = BodeMarkmenu.menu
19212  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
19213  BodeMarkmenu.menu.add_checkbutton(label='Marker (5)', variable=ShowMarkerBP, command=UpdateBodeAll)
19214  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
19215  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
19216  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
19217  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor (d)', variable=ShowBdBCur, value=1)
19218  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor (h)', variable=ShowBdBCur, value=2)
19219  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor (f)', variable=ShowBPCur)
19220  BodeMarkmenu.pack(side=LEFT, anchor=W)
19221  #
19222  # Horz Scale
19223  HzScale = Frame( frame2bp )
19224  HzScale.pack(side=TOP)
19225  brb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
19226  brb1.pack(side=LEFT)
19227  brb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
19228  brb2.pack(side=LEFT)
19229 
19230  DBrange = Frame( frame2bp )
19231  DBrange.pack(side=TOP)
19232  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
19233  bd3.pack(side=LEFT)
19234  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
19235  bd4.pack(side=LEFT)
19236 
19237  LVBrange = Frame( frame2bp )
19238  LVBrange.pack(side=TOP)
19239  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
19240  bd5.pack(side=LEFT)
19241  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
19242  bd6.pack(side=LEFT)
19243 
19244  LVSrange = Frame( frame2bp )
19245  LVSrange.pack(side=TOP)
19246  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
19247  bd7.pack(side=LEFT)
19248  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
19249  bd8.pack(side=LEFT)
19250 
19251  PhaseCenter = Frame( frame2bp )
19252  PhaseCenter.pack(side=TOP)
19253  BPhCenlab = Label(PhaseCenter, text="Center Phase on")
19254  BPhCenlab.pack(side=LEFT)
19255  PhCenBodeEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
19256  PhCenBodeEntry.bind('<Return>', onTextKey)
19257  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
19258  PhCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19259  PhCenBodeEntry.bind("<Button-5>", onTextScroll)
19260  PhCenBodeEntry.bind('<Key>', onTextKey)
19261  PhCenBodeEntry.pack(side=LEFT)
19262  PhCenBodeEntry.delete(0,"end")
19263  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
19264  #
19265  ImpedCenter = Frame( frame2bp )
19266  ImpedCenter.pack(side=TOP)
19267  ImCenlab = Label(ImpedCenter, text="Center Imped on")
19268  ImCenlab.pack(side=LEFT)
19269  ImCenBodeEntry = Entry(ImpedCenter, width=5, cursor='double_arrow')
19270  ImCenBodeEntry.bind('<Return>', onTextKey)
19271  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
19272  ImCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19273  ImCenBodeEntry.bind("<Button-5>", onTextScroll)
19274  ImCenBodeEntry.bind('<Key>', onTextKey)
19275  ImCenBodeEntry.pack(side=LEFT)
19276  ImCenBodeEntry.delete(0,"end")
19277  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
19278  # sweep generator mode menu buttons
19279  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
19280  FSweepmenu.pack(side=TOP)
19281 
19282  Frange1 = Frame( frame2bp )
19283  Frange1.pack(side=TOP)
19284  bstartfreqlab = Label(Frange1, text="Start Freq")
19285  bstartfreqlab.pack(side=LEFT)
19286  StartBodeEntry = Entry(Frange1, width=5, cursor='double_arrow')
19287  StartBodeEntry.bind('<Return>', onTextKey)
19288  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
19289  StartBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19290  StartBodeEntry.bind("<Button-5>", onTextScroll)
19291  StartBodeEntry.bind('<Key>', onTextKey)
19292  StartBodeEntry.pack(side=LEFT)
19293  StartBodeEntry.delete(0,"end")
19294  StartBodeEntry.insert(0,10)
19295 
19296  Frange2 = Frame( frame2bp )
19297  Frange2.pack(side=TOP)
19298  bstopfreqlab = Label(Frange2, text="Stop Freq")
19299  bstopfreqlab.pack(side=LEFT)
19300  StopBodeEntry = Entry(Frange2, width=5, cursor='double_arrow')
19301  StopBodeEntry.bind('<Return>', onTextKey)
19302  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
19303  StopBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19304  StopBodeEntry.bind("<Button-5>", onTextScroll)
19305  StopBodeEntry.bind('<Key>', onTextKey)
19306  StopBodeEntry.pack(side=LEFT)
19307  StopBodeEntry.delete(0,"end")
19308  StopBodeEntry.insert(0,10000)
19309 
19310  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
19311  sgrb1.pack(side=TOP)
19312  Frange4 = Frame( frame2bp )
19313  Frange4.pack(side=TOP)
19314  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
19315  sgrb2.pack(side=LEFT)
19316  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
19317  sgrb3.pack(side=LEFT)
19318  if MinigenScreenStatus.get() > 0:
19319  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
19320  sgrb1.pack(side=TOP)
19321  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
19322  ffcb.pack(side=TOP)
19323  Frange3 = Frame( frame2bp )
19324  Frange3.pack(side=TOP)
19325  sweepsteplab = Label(Frange3, text="Sweep Steps")
19326  sweepsteplab.pack(side=LEFT)
19327  SweepStepBodeEntry = Entry(Frange3, width=5, cursor='double_arrow')
19328  SweepStepBodeEntry.bind('<Return>', onTextKey)
19329  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
19330  SweepStepBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19331  SweepStepBodeEntry.bind("<Button-5>", onTextScroll)
19332  SweepStepBodeEntry.bind('<Key>', onTextKey)
19333  SweepStepBodeEntry.pack(side=LEFT)
19334  SweepStepBodeEntry.delete(0,"end")
19335  SweepStepBodeEntry.insert(0,100)
19336 
19337  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
19338  sgrb5.pack(side=TOP)
19339  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
19340  sgrb6.pack(side=TOP)
19341  Plotsframe = Frame( frame2bp )
19342  Plotsframe.pack(side=TOP)
19343  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
19344  nyquistplotbutton.pack(side=LEFT)
19345  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
19346  nicholsplotbutton.pack(side=LEFT)
19347  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
19348  bodismiss1button.pack(side=TOP)
19349 
19350  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
19351  ADI2.pack(side=TOP)
19352  if ShowBallonHelp > 0:
19353  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
19354  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
19355  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
19356  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
19357  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
19358  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
19359  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
19360  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
19361  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
19362  if LocalLanguage != "English":
19363  BLoadConfig(LocalLanguage) # load local language configuration
19364 #
19366  global bodewindow, BodeScreenStatus, ca, FSweepMode
19367 
19368  BodeScreenStatus.set(0)
19369  FSweepMode.set(0)
19370  BodeDisp.set(0)
19371  BodeCheckBox()
19372  bodewindow.destroy()
19373  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19374 #
19375 def FreqCaresize(event):
19376  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
19377 
19378  CANVASwidthF = event.width - 4
19379  CANVASheightF = event.height - 4
19380  GRWF = CANVASwidthF - 10 - (2 * X0LF) # new grid width
19381  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
19382  UpdateFreqAll()
19383 #
19384 # ================ Make spectrum sub window ==========================
19386  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
19387  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp, ShowAWGASA
19388  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA, ShowAWGBSA
19389  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate, AWGShowAdvanced
19390  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
19391  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
19392  global FrameRefief, BorderSize, LocalLanguage, SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry
19393  global sb_tip, rb_tip, bless_tip, bmore_tip, b3_tip, b4_tip, b5_tip, b6_tip, b7_tip, b8_tip, sadismiss1button_tip
19394  global SAMagdiv, SAVScale, SAvertmaxEntry, SAvertminEntry, SAVPSD
19395 
19396  if SpectrumScreenStatus.get() == 0:
19397  SpectrumScreenStatus.set(1)
19398  FreqDisp.set(1)
19399  FreqCheckBox()
19400  CANVASwidthF = GRWF + 10 + 2 * X0LF # The spectrum canvas width
19401  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
19402  freqwindow = Toplevel()
19403  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
19404  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
19405  frame2fr = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
19406  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
19407 
19408  frame2f = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
19409  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
19410 
19411  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
19412  Freqca.bind('<Configure>', FreqCaresize)
19413  Freqca.bind('<1>', onCanvasFreqLeftClick)
19414  Freqca.bind('<3>', onCanvasFreqRightClick)
19415  Freqca.bind("<Up>", onCanvasUpArrow)
19416  Freqca.bind("<Down>", onCanvasDownArrow)
19417  Freqca.bind("<Left>", onCanvasLeftArrow)
19418  Freqca.bind("<Right>", onCanvasRightArrow)
19419  Freqca.bind("<space>", onCanvasSpaceBar)
19420  Freqca.bind("1", onCanvasSAOne)
19421  Freqca.bind("2", onCanvasSATwo)
19422  Freqca.bind("3", onCanvasSAThree)
19423  Freqca.bind("4", onCanvasSAFour)
19424  Freqca.bind("5", onCanvasSAFive)
19425  Freqca.bind("6", onCanvasSASix)
19426  Freqca.bind("7", onCanvasSASeven)
19427  Freqca.bind("8", onCanvasSAEight)
19428  Freqca.bind("9", onCanvasSANine)
19429  Freqca.bind("0", onCanvasSAZero)
19430  Freqca.bind("a", onCanvasSAAverage)
19431  Freqca.bind("n", onCanvasSANormal)
19432  Freqca.bind("p", onCanvasSAPeak)
19433  Freqca.bind("r", onCanvasSAReset)
19434  Freqca.bind("f", onCanvasShowFcur)
19435  Freqca.bind("d", onCanvasShowdBcur)
19436  Freqca.bind("h", onCanvasShowPcur)
19437  Freqca.bind("s", onCanvasSASnap)
19438  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
19439  # right side drop down menu buttons
19440  dropmenu = Frame( frame2fr )
19441  dropmenu.pack(side=TOP)
19442  # File menu
19443  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19444  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
19445  SAFilemenu["menu"] = SAFilemenu.menu
19446  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
19447  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
19448  SAFilemenu.menu.add_command(label="Run Script", command=RunScript)
19449  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
19450  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
19451  SAFilemenu.pack(side=LEFT, anchor=W)
19452  #
19453  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19454  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
19455  SAOptionmenu["menu"] = SAOptionmenu.menu
19456  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19457  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
19458  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
19459  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19460  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
19461  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19462  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19463  SAOptionmenu.pack(side=LEFT, anchor=W)
19464  #
19465  RUNframe = Frame( frame2fr )
19466  RUNframe.pack(side=TOP)
19467  sarb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
19468  sarb.pack(side=LEFT)
19469  sasb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
19470  sasb.pack(side=LEFT)
19471  #
19472  Modeframe = Frame( frame2fr )
19473  Modeframe.pack(side=TOP)
19474  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
19475  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
19476  Modemenu["menu"] = Modemenu.menu
19477  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
19478  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
19479  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
19480  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
19481  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
19482  Modemenu.pack(side=LEFT)
19483  #
19484  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
19485  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
19486  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
19487  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19488  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19489  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19490  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19491  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19492  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19493  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19494  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19495  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19496  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19497  SAFFTwindmenu.pack(side=LEFT)
19498  #
19499  SamplesMenu = Frame( frame2fr )
19500  SamplesMenu.pack(side=TOP)
19501  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
19502  bless.pack(side=LEFT)
19503  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
19504  bmore.pack(side=LEFT)
19505  #
19506  # Show channels menu
19507  #
19508  MarkersMenu = Frame( frame2fr )
19509  MarkersMenu.pack(side=TOP)
19510  SAShowmenu = Menubutton(MarkersMenu, text="Curves", style="W7.TButton")
19511  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
19512  SAShowmenu["menu"] = SAShowmenu.menu
19513  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
19514  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
19515  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
19516  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
19517  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
19518  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
19519  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
19520  SAShowmenu.menu.add_command(label="-Math-", command=donothing)
19521  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
19522  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
19523  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
19524  if AWGShowAdvanced.get() > 0:
19525  SAShowmenu.menu.add_command(label="-AWG-", command=donothing)
19526  SAShowmenu.menu.add_checkbutton(label='AWG A', variable=ShowAWGASA, command=UpdateFreqAll)
19527  SAShowmenu.menu.add_checkbutton(label='AWG B', variable=ShowAWGBSA, command=UpdateFreqAll)
19528  SAShowmenu.menu.add_command(label="-Ref Trace-", command=donothing)
19529  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
19530  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
19531  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
19532  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
19533  SAShowmenu.menu.add_checkbutton(label='Ref Math', variable=ShowRMath, command=UpdateFreqAll)
19534  SAShowmenu.pack(side=LEFT)
19535  SACursormenu = Menubutton(MarkersMenu, text="Cursors", style="W7.TButton")
19536  SACursormenu.menu = Menu(SACursormenu, tearoff = 0 )
19537  SACursormenu["menu"] = SACursormenu.menu
19538  SACursormenu.menu.add_command(label="-Marker-", command=donothing)
19539  SACursormenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
19540  SACursormenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
19541  SACursormenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
19542  SACursormenu.menu.add_command(label="-Cursors-", command=donothing)
19543  SACursormenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
19544  SACursormenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
19545  #SACursormenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
19546  SACursormenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
19547  SACursormenu.pack(side=LEFT)
19548  # HScale
19549  Frange1 = Frame( frame2fr )
19550  Frange1.pack(side=TOP)
19551  startfreqlab = Label(Frange1, text="Startfreq")
19552  startfreqlab.pack(side=LEFT)
19553  StartFreqEntry = Entry(Frange1, width=5, cursor='double_arrow')
19554  StartFreqEntry.bind('<Return>', onTextKey)
19555  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
19556  StartFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19557  StartFreqEntry.bind("<Button-5>", onTextScroll)
19558  StartFreqEntry.bind('<Key>', onTextKey)
19559  StartFreqEntry.pack(side=LEFT)
19560  StartFreqEntry.delete(0,"end")
19561  StartFreqEntry.insert(0,10)
19562 
19563  Frange2 = Frame( frame2fr )
19564  Frange2.pack(side=TOP)
19565  stopfreqlab = Label(Frange2, text="Stopfreq")
19566  stopfreqlab.pack(side=LEFT)
19567  StopFreqEntry = Entry(Frange2, width=7, cursor='double_arrow')
19568  StopFreqEntry.bind('<Return>', onTextKey)
19569  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
19570  StopFreqEntry.bind("<Button-4>", onStopfreqScroll)# with Linux OS
19571  StopFreqEntry.bind("<Button-5>", onStopfreqScroll)
19572  StopFreqEntry.bind('<Key>', onTextKey)
19573  StopFreqEntry.pack(side=LEFT)
19574  StopFreqEntry.delete(0,"end")
19575  StopFreqEntry.insert(0,10000)
19576 
19577  HzScale = Frame( frame2fr )
19578  HzScale.pack(side=TOP)
19579  sarb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
19580  sarb1.pack(side=LEFT)
19581  sarb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
19582  sarb2.pack(side=LEFT)
19583  #
19584  PhaseCenter = Frame( frame2fr )
19585  PhaseCenter.pack(side=TOP)
19586  PhCenlab = Label(PhaseCenter, text="Center Phase on")
19587  PhCenlab.pack(side=LEFT)
19588  PhCenFreqEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
19589  PhCenFreqEntry.bind('<Return>', onTextKey)
19590  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
19591  PhCenFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19592  PhCenFreqEntry.bind("<Button-5>", onTextScroll)
19593  PhCenFreqEntry.bind('<Key>', onTextKey)
19594  PhCenFreqEntry.pack(side=LEFT)
19595  PhCenFreqEntry.delete(0,"end")
19596  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
19597  #
19598  vertlabel = Label( frame2fr, text="Vertical Scale" )
19599  vertlabel.pack(side=TOP)
19600  savrb0 = Radiobutton(frame2fr, text="In dB", variable=SAVScale, value=0, command=UpdateFreqTrace )
19601  savrb0.pack(side=TOP)
19602  #
19603  DBrange = Frame( frame2fr )
19604  DBrange.pack(side=TOP)
19605  sab3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
19606  sab3.pack(side=LEFT)
19607  sab4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
19608  sab4.pack(side=LEFT)
19609 
19610  LVBrange = Frame( frame2fr )
19611  LVBrange.pack(side=TOP)
19612  sab5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
19613  sab5.pack(side=LEFT)
19614  sab6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
19615  sab6.pack(side=LEFT)
19616 
19617  LVSrange = Frame( frame2fr )
19618  LVSrange.pack(side=TOP)
19619  sab7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
19620  sab7.pack(side=LEFT)
19621  sab8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
19622  sab8.pack(side=LEFT)
19623  # Add RMS V controls
19624  vertscale = Frame( frame2fr )
19625  vertscale.pack(side=TOP)
19626  savlab1 = Label(vertscale, text="V RMS")
19627  savlab1.pack(side=LEFT)
19628  savrb1 = Radiobutton(vertscale, text="Lin", variable=SAVScale, value=1, command=UpdateFreqTrace )
19629  savrb1.pack(side=LEFT)
19630  savrb2 = Radiobutton(vertscale, text="Log", variable=SAVScale, value=2, command=UpdateFreqTrace )
19631  savrb2.pack(side=LEFT)
19632  sapsdcb = Checkbutton(frame2fr, text="PSD (sqrt Hz)", variable=SAVPSD)
19633  sapsdcb.pack(side=TOP)
19634  #
19635  vertmax = Frame( frame2fr )
19636  vertmax.pack(side=TOP)
19637  vertmaxlab = Label(vertmax, text="VRMS Max")
19638  vertmaxlab.pack(side=LEFT)
19639  SAvertmaxEntry = Spinbox(vertmax, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
19640  SAvertmaxEntry.bind('<MouseWheel>', onSpinBoxScroll)
19641  SAvertmaxEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19642  SAvertmaxEntry.bind("<Button-5>", onSpinBoxScroll)
19643  SAvertmaxEntry.delete(0,"end")
19644  SAvertmaxEntry.insert(0,"1.0")
19645  SAvertmaxEntry.pack(side=LEFT)
19646 
19656  vertmin = Frame( frame2fr )
19657  vertmin.pack(side=TOP)
19658  vertminlab = Label(vertmin, text="VRMS Min")
19659  vertminlab.pack(side=LEFT)
19660  SAvertminEntry = Spinbox(vertmin, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
19661  SAvertminEntry.bind('<MouseWheel>', onSpinBoxScroll)
19662  SAvertminEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19663  SAvertminEntry.bind("<Button-5>", onSpinBoxScroll)
19664  SAvertminEntry.pack(side=LEFT)
19665  SAvertminEntry.delete(0,"end")
19666  SAvertminEntry.insert(0,"100uV")
19667 
19677  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
19678  sadismiss1button.pack(side=TOP)
19679 
19680  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
19681  ADI2.pack(side=TOP)
19682  if ShowBallonHelp > 0:
19683  sb_tip = CreateToolTip(sasb, 'Stop acquiring data')
19684  rb_tip = CreateToolTip(sarb, 'Start acquiring data')
19685  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
19686  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
19687  b3_tip = CreateToolTip(sab3, 'Increase number of dB/Div')
19688  b4_tip = CreateToolTip(sab4, 'Decrease number of dB/Div')
19689  b5_tip = CreateToolTip(sab5, 'Increase Ref Level by 10 dB')
19690  b6_tip = CreateToolTip(sab6, 'Decrease Ref Level by 10 dB')
19691  b7_tip = CreateToolTip(sab7, 'Increase Ref Level by 1 dB')
19692  b8_tip = CreateToolTip(sab8, 'Decrease Ref Level by 1 dB')
19693  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
19694  if LocalLanguage != "English":
19695  BLoadConfig(LocalLanguage) # load local language configuration
19696 
19698  global freqwindow, SpectrumScreenStatus, ca
19699 
19700  SpectrumScreenStatus.set(0)
19701  FreqDisp.set(0)
19702  FreqCheckBox()
19703  freqwindow.destroy()
19704  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19705 #
19706 def XYcaresize(event):
19707  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
19708  global YminXY, YmaxXY, XminXY, XmaxXY
19709 
19710  XOLXY = FontSize * 7
19711  CANVASwidthXY = event.width - 4
19712  CANVASheightXY = event.height - 4
19713  GRWXY = CANVASwidthXY - (2*X0LXY) # 18 new grid width
19714  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
19715  YminXY = Y0TXY # Minimum position of time grid (top)
19716  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
19717  XminXY = X0LXY # Minimum position of time grid (left)
19718  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
19719  UpdateXYAll()
19720 #
19721 # ================ Make XY Plot sub window ==========================
19723  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, EnableUserEntries
19724  global YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
19725  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
19726  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
19727  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
19728  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
19729  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
19730  global FrameRefief, BorderSize, LocalLanguage, User3Entry, User4Entry
19731  global math_tip, bsxy_tip, brxy_tip, snapbutton_tip, savebutton_tip, dismissxybutton_tip, CHAxylab_tip
19732  global CHBxylab_tip, CHAxyofflab_tip, CHBxyofflab_tip, CHAIxyofflab_tip, CHBIxyofflab_tip
19733 
19734  if XYScreenStatus.get() == 0:
19735  XYScreenStatus.set(1)
19736  XYDisp.set(1)
19737  XYCheckBox()
19738  YminXY = Y0TXY # Minimum position of XY grid (top)
19739  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
19740  XminXY = X0LXY # Minimum position of XY grid (left)
19741  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
19742  CANVASwidthXY = GRWXY + (2*X0LXY) # The XY canvas width
19743  CANVASheightXY = GRHXY + 80 # The XY canvas height
19744  xywindow = Toplevel()
19745  xywindow.title("X-Y Plot " + SWRev + RevDate)
19746  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
19747  frame2xyr = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19748  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
19749 
19750  frame2xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19751  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
19752 
19753  frame3xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19754  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
19755 
19756  frame4xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19757  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
19758 
19759  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
19760  XYca.bind('<Configure>', XYcaresize)
19761  XYca.bind('<1>', onCanvasXYLeftClick)
19762  XYca.bind('<3>', onCanvasXYRightClick)
19763  XYca.bind("<Motion>",onCanvasMouse_xy)
19764  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
19765  XYca.bind("<Button-4>", onCanvasXYScrollClick)# with Linux OS
19766  XYca.bind("<Button-5>", onCanvasXYScrollClick)
19767  XYca.bind("<Up>", onCanvasUpArrow)
19768  XYca.bind("<Down>", onCanvasDownArrow)
19769  XYca.bind("<Left>", onCanvasLeftArrow)
19770  XYca.bind("<Right>", onCanvasRightArrow)
19771  XYca.bind("<space>", onCanvasSpaceBar)
19772  XYca.bind("a", onCanvasAverage)
19773  XYca.pack(side=TOP, fill=BOTH, expand=YES)
19774  #
19775  RUNframe = Frame( frame2xyr )
19776  RUNframe.pack(side=TOP)
19777  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
19778  rbxy.pack(side=LEFT)
19779  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
19780  sbxy.pack(side=LEFT)
19781  # Open Math trace menu
19782  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
19783  mathbt.pack(side=TOP) #, anchor=W)
19784  # Disply mode menu
19785  # X - Y mode signal select
19786  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
19787  AxisLabX.pack(side=TOP)
19788  chaxmenu = Frame( frame2xyr )
19789  chaxmenu.pack(side=TOP)
19790  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
19791  rbx2.pack(side=LEFT, anchor=W)
19792  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
19793  rbx3.pack(side=LEFT, anchor=W)
19794  chbxmenu = Frame( frame2xyr )
19795  chbxmenu.pack(side=TOP)
19796  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
19797  rbx4.pack(side=LEFT, anchor=W)
19798  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
19799  rbx5.pack(side=LEFT, anchor=W)
19800  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
19801  rbx7.pack(side=TOP)
19802  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
19803  rbx8.pack(side=TOP)
19804  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
19805  rbx6.pack(side=TOP)
19806  #
19807  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
19808  AxisLabY.pack(side=TOP)
19809  chaymenu = Frame( frame2xyr )
19810  chaymenu.pack(side=TOP)
19811  rby2 = Checkbutton(chaymenu, text='CA-V', variable=YsignalVA, command=UpdateXYTrace)
19812  rby2.pack(side=LEFT, anchor=W)
19813  rby3 = Checkbutton(chaymenu, text='CA-I', variable=YsignalIA, command=UpdateXYTrace)
19814  rby3.pack(side=LEFT, anchor=W)
19815  chbymenu = Frame( frame2xyr )
19816  chbymenu.pack(side=TOP)
19817  rby4 = Checkbutton(chbymenu, text='CB-V', variable=YsignalVB, command=UpdateXYTrace)
19818  rby4.pack(side=LEFT, anchor=W)
19819  rby5 = Checkbutton(chbymenu, text='CB-I', variable=YsignalIB, command=UpdateXYTrace)
19820  rby5.pack(side=LEFT, anchor=W)
19821  rby7 = Checkbutton(frame2xyr, text='Math', variable=YsignalM, command=UpdateXYTrace)
19822  rby7.pack(side=TOP)
19823  mymenu = Frame( frame2xyr )
19824  mymenu.pack(side=TOP)
19825  rby7 = Checkbutton(mymenu, text='Math-X', variable=YsignalMX, command=UpdateXYTrace)
19826  rby7.pack(side=LEFT, anchor=W)
19827  rby8 = Checkbutton(mymenu, text='Math-Y', variable=YsignalMY, command=UpdateXYTrace)
19828  rby8.pack(side=LEFT, anchor=W)
19829  # show cursor menu buttons
19830  cursormenu = Frame( frame2xyr )
19831  cursormenu.pack(side=TOP)
19832  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
19833  cb1.pack(side=LEFT, anchor=W)
19834  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
19835  cb2.pack(side=LEFT, anchor=W)
19836  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
19837  cb4.pack(side=TOP)
19838  #
19839  # Reference trace menu
19840  XYrefmenu = Menubutton(frame2xyr, text="Ref Traces", style="W11.TButton")
19841  XYrefmenu.menu = Menu(XYrefmenu, tearoff = 0 )
19842  XYrefmenu["menu"] = XYrefmenu.menu
19843  XYrefmenu.menu.add_command(label="Save SnapShot", command=BSnapShotXY)
19844  XYrefmenu.menu.add_checkbutton(label="CA-V", variable=XYRefAV, command=UpdateXYTrace)
19845  XYrefmenu.menu.add_checkbutton(label="CA-I", variable=XYRefAI, command=UpdateXYTrace)
19846  XYrefmenu.menu.add_checkbutton(label="CB-V", variable=XYRefBV, command=UpdateXYTrace)
19847  XYrefmenu.menu.add_checkbutton(label="CB-I", variable=XYRefBI, command=UpdateXYTrace)
19848  XYrefmenu.menu.add_checkbutton(label="Math", variable=XYRefM, command=UpdateXYTrace)
19849  XYrefmenu.menu.add_checkbutton(label="Math-X", variable=XYRefMX, command=UpdateXYTrace)
19850  XYrefmenu.menu.add_checkbutton(label="Math-Y", variable=XYRefMY, command=UpdateXYTrace)
19851  XYrefmenu.pack(side=TOP) # , anchor=W)
19852 
19854  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
19855  dismissxybutton.pack(side=TOP)
19856  # Add a pair of user entry wigets
19857  if EnableUserEntries > 0:
19858  UserEnt = Frame( frame2xyr )
19859  UserEnt.pack(side=TOP)
19860  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
19861  userentlab.pack(side=LEFT,fill=X)
19862  User3Entry = Entry(UserEnt, width=5, cursor='double_arrow')
19863  User3Entry.bind('<Return>', onTextKey)
19864  User3Entry.bind('<MouseWheel>', onTextScroll)
19865  User3Entry.bind("<Button-4>", onTextScroll)# with Linux OS
19866  User3Entry.bind("<Button-5>", onTextScroll)
19867  User3Entry.bind('<Key>', onTextKey)
19868  User3Entry.pack(side=LEFT)
19869  User3Entry.delete(0,"end")
19870  User3Entry.insert(0,0.0)
19871  User4Entry = Entry(UserEnt, width=5, cursor='double_arrow')
19872  User4Entry.bind('<Return>', onTextKey)
19873  User4Entry.bind('<MouseWheel>', onTextScroll)
19874  User4Entry.bind("<Button-4>", onTextScroll)# with Linux OS
19875  User4Entry.bind("<Button-5>", onTextScroll)
19876  User4Entry.bind('<Key>', onTextKey)
19877  User4Entry.pack(side=LEFT)
19878  User4Entry.delete(0,"end")
19879  User4Entry.insert(0,0.0)
19880  #
19881  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
19882  ADI1xy.pack(side=TOP)
19883  # Bottom Buttons
19884  MarkerXYScale = IntVar(0)
19885  MarkerXYScale.set(1)
19886  # Voltage channel A
19887  CHAsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHvpdiv)
19888  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19889  CHAsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19890  CHAsbxy.bind("<Button-5>", onSpinBoxScroll)
19891  CHAsbxy.pack(side=LEFT)
19892  CHAsbxy.delete(0,"end")
19893  CHAsbxy.insert(0,0.5)
19894  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
19895  CHAxylab.pack(side=LEFT)
19896 
19897  CHAVPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
19898  CHAVPosEntryxy.bind('<Return>', onTextKey)
19899  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
19900  CHAVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19901  CHAVPosEntryxy.bind("<Button-5>", onTextScroll)
19902  CHAVPosEntryxy.bind('<Key>', onTextKey)
19903  CHAVPosEntryxy.pack(side=LEFT)
19904  CHAVPosEntryxy.delete(0,"end")
19905  CHAVPosEntryxy.insert(0,2.5)
19906  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
19907  CHAofflabxy.pack(side=LEFT)
19908  # Current channel A
19909  CHAIsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHipdiv)
19910  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19911  CHAIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19912  CHAIsbxy.bind("<Button-5>", onSpinBoxScroll)
19913  CHAIsbxy.pack(side=LEFT)
19914  CHAIsbxy.delete(0,"end")
19915  CHAIsbxy.insert(0,50.0)
19916  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
19917  CHAIlabxy.pack(side=LEFT)
19918 
19919  CHAIPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
19920  CHAIPosEntryxy.bind('<Return>', onTextKey)
19921  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
19922  CHAIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19923  CHAIPosEntryxy.bind("<Button-5>", onTextScroll)
19924  CHAIPosEntryxy.bind('<Key>', onTextKey)
19925  CHAIPosEntryxy.pack(side=LEFT)
19926  CHAIPosEntryxy.delete(0,"end")
19927  CHAIPosEntryxy.insert(0,0.0)
19928  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
19929  CHAIofflabxy.pack(side=LEFT)
19930  # Voltage channel B
19931  CHBsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHvpdiv)
19932  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19933  CHBsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19934  CHBsbxy.bind("<Button-5>", onSpinBoxScroll)
19935  CHBsbxy.pack(side=LEFT)
19936  CHBsbxy.delete(0,"end")
19937  CHBsbxy.insert(0,0.5)
19938  #
19939  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
19940  CHBxylab.pack(side=LEFT)
19941 
19942  CHBVPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
19943  CHBVPosEntryxy.bind('<Return>', onTextKey)
19944  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
19945  CHBVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19946  CHBVPosEntryxy.bind("<Button-5>", onTextScroll)
19947  CHBVPosEntryxy.bind('<Key>', onTextKey)
19948  CHBVPosEntryxy.pack(side=LEFT)
19949  CHBVPosEntryxy.delete(0,"end")
19950  CHBVPosEntryxy.insert(0,2.5)
19951  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
19952  CHBofflabxy.pack(side=LEFT)
19953  # Current channel B
19954  CHBIsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHipdiv) #
19955  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19956  CHBIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19957  CHBIsbxy.bind("<Button-5>", onSpinBoxScroll)
19958  CHBIsbxy.pack(side=LEFT)
19959  CHBIsbxy.delete(0,"end")
19960  CHBIsbxy.insert(0,50.0)
19961  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
19962  CHBIlabxy.pack(side=LEFT)
19963 
19964  CHBIPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
19965  CHBIPosEntryxy.bind('<Return>', onTextKey)
19966  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
19967  CHBIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19968  CHBIPosEntryxy.bind("<Button-5>", onTextScroll)
19969  CHBIPosEntryxy.bind('<Key>', onTextKey)
19970  CHBIPosEntryxy.pack(side=LEFT)
19971  CHBIPosEntryxy.delete(0,"end")
19972  CHBIPosEntryxy.insert(0,0.0)
19973  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
19974  CHBIofflabxy.pack(side=LEFT)
19975  #
19976  if ShowBallonHelp > 0:
19977  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
19978  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
19979  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
19980  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
19981  math_tip = CreateToolTip(mathbt, 'Open Math window')
19982  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
19983  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
19984  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
19985  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
19986  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
19987  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
19988  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
19989  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
19990  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
19991  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
19992  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
19993  if LocalLanguage != "English":
19994  BLoadConfig(LocalLanguage)
19995 
19997  global xywindow, XYScreenStatus, ca, XYDisp
19998 
19999  XYScreenStatus.set(0)
20000  XYDisp.set(0)
20001  XYCheckBox()
20002  xywindow.destroy()
20003  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20004 #
20005 # Optional Calibration procedure routine
20006 #
20008  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
20009  global discontloop, contloop, session, AWGSync, SWRev
20010  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
20011  # setup cal results window
20012  if FWRevOne < 2.06: # Check firmware revision level > 2.06
20013  showwarning("WARNING","Out of date Firmware Revision!")
20014  return
20015  calwindow = Toplevel()
20016  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
20017  # display wigets
20018  SCallab = Label(calwindow, text="Channel Gain / Offset calibration")
20019  SCallab.grid(row=0, column=0, columnspan=2, sticky=W)
20020  labelA0 = Label(calwindow, style="A12B.TLabel")
20021  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
20022  labelA0.config(text = "CA gnd Volts")
20023  labelAMax = Label(calwindow, style="A12B.TLabel")
20024  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
20025  labelAMax.config(text = "CA 584 Volts")
20026  labelAMin = Label(calwindow, style="A12B.TLabel")
20027  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
20028  labelAMin.config(text = "CA 5V Src I ")
20029  labelB0 = Label(calwindow, style="A12B.TLabel")
20030  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
20031  labelB0.config(text = "CA gnd Volts")
20032  labelBMax = Label(calwindow, style="A12B.TLabel")
20033  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
20034  labelBMax.config(text = "CB 584 Volts")
20035  labelBMin = Label(calwindow, style="A12B.TLabel")
20036  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
20037  labelBMin.config(text = "CB 5V Src I ")
20038  labelAB = Label(calwindow, style="A12B.TLabel")
20039  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
20040  labelAB.config(text = "CA 0V Src I")
20041  labelBA = Label(calwindow, style="A12B.TLabel")
20042  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
20043  labelBA.config(text = "CA 0V Src I")
20044  labelSIA0 = Label(calwindow, style="A12B.TLabel")
20045  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
20046  labelSIA0.config(text = "CA 2.5 Src 0 I")
20047  labelSIA = Label(calwindow, style="A12B.TLabel")
20048  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
20049  labelSIA.config(text = "CA 50 Src 100 ")
20050  labelSIAN = Label(calwindow, style="A12B.TLabel")
20051  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
20052  labelSIAN.config(text = "CA 50 Src -45")
20053  labelSIB0 = Label(calwindow, style="A12B.TLabel")
20054  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
20055  labelSIB0.config(text = "CB 2.5 Src 0 I")
20056  labelSIB = Label(calwindow, style="A12B.TLabel")
20057  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
20058  labelSIB.config(text = "CB 50 Src 100 ")
20059  labelSIBN = Label(calwindow, style="A12B.TLabel")
20060  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
20061  labelSIBN.config(text = "CB 50 Src -45")
20062  # set to default mux and dac settings
20063  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
20064  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
20065  AWGSync.set(1)
20066  BAWGSync()
20067  if session.continuous:
20068  print( "ending session")
20069  session.end()
20070  # Setup ADALM1000
20071  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
20072  #print(devx.calibration)
20073  try:
20074  devx.write_calibration("calib_default.txt")
20075  #print "wrote calib_default.txt"
20076  except:
20077  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
20078  devx.write_calibration(filename)
20079  #print(devx.calibration)
20080  #
20081  devidstr = DevID[17:31]
20082  filename = "calib" + devidstr + ".txt"
20083  if os.path.isfile(filename):
20084  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
20085  devx.write_calibration(filename)
20086  #print "wrote old ", filename
20087  calwindow.destroy()
20088  return
20089  else:
20090  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
20091  donothing()
20092  else:
20093  calwindow.destroy()
20094  return
20095  #
20096  CalFile = open(filename, "w")
20097  #
20098  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20099  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20100  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
20101  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
20102  ADsignal1 = [] # Ain signal array channel
20103  ADsignal1 = devx.get_samples(1010)
20104  # Pause whie user connects external voltage reference AD584
20105  BadData = 1
20106  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20107  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20108  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20109  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20110  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
20111  try:
20112  AD584act = float(RequestVRef)*1.0
20113  except:
20114  AD584act = 3.3
20115  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
20116  while (BadData): # loop till good reading
20117  # Get A and B AD584 data
20118  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20119  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20120  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20121  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
20122  # get_samples returns a list of values for voltage [0] and current [1]
20123  for index in range(1000): # calculate average
20124  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20125  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20126 
20127  CHA584Raw = CHA584Raw / 1000.0 # calculate average
20128  CHB584Raw = CHB584Raw / 1000.0 # calculate average
20129  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
20130  labelAMax.config(text = VString) # change displayed value
20131  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
20132  labelBMax.config(text = VString) # change displayed value
20133  Lower = AD584act - 0.3
20134  Upper = AD584act + 0.3
20135  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
20136  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
20137  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20138  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20139  contloop = 0
20140  discontloop = 1
20141  calwindow.destroy()
20142  return
20143  else:
20144  BadData = 0
20145  #
20146  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
20147  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
20148  # Get A GND and B GND data
20149  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20150  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
20151  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20152  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20153  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20154  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20155  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20156  # get_samples returns a list of values for voltage [0] and current [1]
20157  for index in range(1000): # calculate average
20158  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20159  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20160  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20161  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20162 
20163  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
20164  CHAI0gRaw = CHAI0gRaw / 1000.0
20165  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
20166  CHBI0gRaw = CHBI0gRaw / 1000.0
20167  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
20168  labelA0.config(text = VString) # change displayed value
20169  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
20170  labelB0.config(text = VString) # change displayed value
20171  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
20172  # Get A and B data for internal 2.5 rail
20173  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20174  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20175  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
20176  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20177  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20178  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20179  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20180  # get_samples returns a list of values for voltage [0] and current [1]
20181  for index in range(1000): # calculate average
20182  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20183  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20184  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20185  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20186 
20187  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
20188  CHAI02p5Raw = CHAI02p5Raw / 1000.0
20189  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
20190  CHBI02p5Raw = CHBI02p5Raw / 1000.0
20191  # Get A force 0V and B force 0V data
20192  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20193  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20194  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20195  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20196  CHA.mode = Mode.SVMI
20197  CHA.constant(0.0)
20198  CHB.mode = Mode.SVMI
20199  CHB.constant(0.0)
20200  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20201  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
20202  # get_samples returns a list of values for voltage [0] and current [1]
20203  for index in range(1000): # calculate average
20204  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20205  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20206  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20207  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20208 
20209  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
20210  CHAI0F0Raw = CHAI0F0Raw / 1000.0
20211  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
20212  CHBI0F0Raw = CHBI0F0Raw / 1000.0
20213  # Get A force 2.5V and B force 2.5V data
20214  CHA.mode = Mode.SVMI
20215  CHA.constant(4.5)
20216  CHB.mode = Mode.SVMI
20217  CHB.constant(4.5)
20218  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20219  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
20220  # get_samples returns a list of values for voltage [0] and current [1]
20221  for index in range(1000): # calculate average
20222  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20223  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20224  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20225  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20226 
20227  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
20228  CHAI0F25Raw = CHAI0F25Raw / 1000.0
20229  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
20230  CHBI0F25Raw = CHBI0F25Raw / 1000.0
20231  #
20232  # Get A and B measure current data for int 50 res to gnd at 5V
20233  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
20234  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
20235  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20236  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20237  CHA.mode = Mode.SVMI
20238  CHA.constant(5.0)
20239  CHB.mode = Mode.SVMI
20240  CHB.constant(5.0)
20241  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20242  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
20243  for index in range(1000): # calculate average
20244  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20245  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20246  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20247  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20248 
20249  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
20250  CHAISr5vRaw = CHAISr5vRaw / 1000.0
20251  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
20252  CHBISr5vRaw = CHBISr5vRaw / 1000.0
20253  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
20254  labelAMin.config(text = VString) # change displayed value
20255  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
20256  labelBMin.config(text = VString) # change displayed value
20257  # Get A and B measure current data for int 50 res to 2.5 V at 0V
20258  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20259  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20260  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20261  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20262  CHA.mode = Mode.SVMI
20263  CHA.constant(0.001)
20264  CHB.mode = Mode.SVMI
20265  CHB.constant(0.001)
20266  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20267  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
20268  for index in range(1000): # calculate average
20269  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20270  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20271  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20272  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20273 
20274  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
20275  CHAISr0vRaw = CHAISr0vRaw / 1000.0
20276  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
20277  CHBISr0vRaw = CHBISr0vRaw / 1000.0
20278  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
20279  labelAB.config(text = VString) # change displayed value
20280  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
20281  labelBA.config(text = VString) # change displayed value
20282 
20283  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
20284  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20285  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20286  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20287  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20288  CHA.mode = Mode.SIMV
20289  CHA.constant(0.0)
20290  CHB.mode = Mode.SIMV
20291  CHB.constant(0.0)
20292  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20293  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
20294  for index in range(1000): # calculate average
20295  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20296  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20297  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20298  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20299 
20300  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
20301  CHAISr0iRaw = CHAISr0iRaw / 1000.0
20302  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
20303  CHBISr0iRaw = CHBISr0iRaw / 1000.0
20304  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
20305  labelSIA0.config(text = VString) # change displayed value
20306  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
20307  labelSIB0.config(text = VString) # change displayed value
20308  #
20309  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
20310  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20311  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20312  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20313  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20314  CHA.mode = Mode.SIMV
20315  CHA.constant(0.045)
20316  CHB.mode = Mode.SIMV
20317  CHB.constant(0.045)
20318  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20319  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
20320  for index in range(1000): # calculate average
20321  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20322  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20323  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20324  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20325 
20326  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
20327  CHAISr100Raw = CHAISr100Raw / 1000.0
20328  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
20329  CHBISr100Raw = CHBISr100Raw / 1000.0
20330  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
20331  labelSIA.config(text = VString) # change displayed value
20332  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
20333  labelSIB.config(text = VString) # change displayed value
20334  #
20335  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
20336  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20337  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20338  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20339  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20340  CHA.mode = Mode.SIMV
20341  CHA.constant(-0.045)
20342  CHB.mode = Mode.SIMV
20343  CHB.constant(-0.045)
20344  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20345  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
20346  for index in range(1000): # calculate average
20347  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20348  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20349  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20350  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20351 
20352  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
20353  CHAISrN45Raw = CHAISrN45Raw / 1000.0
20354  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
20355  CHBISrN45Raw = CHBISrN45Raw / 1000.0
20356  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
20357  labelSIAN.config(text = VString) # change displayed value
20358  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
20359  labelSIBN.config(text = VString) # change displayed value
20360  # return all switches to open
20361  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20362  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20363  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20364  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20365  # Caculate voltage gain errors
20366  #
20367  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
20368  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
20369  #
20370  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
20371  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
20372  #
20373  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
20374  # print "calculated fixed 2.5 from CHA ", CHA2p5
20375  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
20376  # print "calculated fixed 2.5 from CHB ", CHB2p5
20377  #
20378  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
20379  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
20380  #
20381  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
20382  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
20383  #
20384  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
20385  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
20386  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
20387  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
20388  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
20389  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
20390  #
20391  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
20392  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
20393  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
20394  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
20395  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
20396  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
20397  # Write cal factors to file
20398  #
20399  CalFile.write('# Channel A, measure V\n')
20400  CalFile.write('</>\n')
20401  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
20402  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
20403  CalFile.write('<>\n')
20404  CalFile.write('\n')
20405  #
20406  CalFile.write('# Channel A, measure I\n')
20407  CalFile.write('</>\n')
20408  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
20409  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
20410  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
20411  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
20412  CalFile.write('<>\n')
20413  CalFile.write('\n')
20414  #
20415  CalFile.write('# Channel A, source V\n')
20416  CalFile.write('</>\n')
20417  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
20418  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
20419  CalFile.write('<>\n')
20420  CalFile.write('\n')
20421  #
20422  CalFile.write('# Channel A, source I\n')
20423  CalFile.write('</>\n')
20424  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
20425  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
20426  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
20427  CalFile.write('<>\n')
20428  CalFile.write('\n')
20429  #
20430  CalFile.write('# Channel B, measure V\n')
20431  CalFile.write('</>\n')
20432  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
20433  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
20434  CalFile.write('<>\n')
20435  CalFile.write('\n')
20436  #
20437  CalFile.write('# Channel B, measure I\n')
20438  CalFile.write('</>\n')
20439  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
20440  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
20441  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
20442  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
20443  CalFile.write('<>\n')
20444  CalFile.write('\n')
20445  #
20446  CalFile.write('# Channel B, source V\n')
20447  CalFile.write('</>\n')
20448  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
20449  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
20450  CalFile.write('<>\n')
20451  CalFile.write('\n')
20452  #
20453  CalFile.write('# Channel B source I\n')
20454  CalFile.write('</>\n')
20455  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
20456  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
20457  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
20458  CalFile.write('<>\n')
20459  #
20460  CalFile.close()
20461  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
20462  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
20463  devx.write_calibration(filename)
20464  #print "wrote new " , filename
20465  #
20466  # session.end()
20467  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
20468  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
20469  contloop = 0
20470  discontloop = 1
20471  # session.cancel()
20472  calwindow.destroy()
20473 #
20475  global cal, DevID, devx
20476 
20477  devidstr = DevID[17:31]
20478  filename = "calib" + devidstr + "test.txt"
20479  if os.path.isfile(filename):
20480  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
20481  return
20482  else:
20483  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
20484  donothing()
20485  else:
20486  calwindow.destroy()
20487  return
20488  #
20489  CalFile = open(filename, "w")
20490  #
20491  # Write cal factors to file
20492  # [0]
20493  CalFile.write('# Channel A, measure V\n')
20494  CalFile.write('</>\n')
20495  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
20496  CHAgp = (5.0/cal[0][1])+cal[0][0]
20497  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20498  CalFile.write('<>\n')
20499  CalFile.write('\n')
20500  # [1]
20501  CalFile.write('# Channel A, measure I\n')
20502  CalFile.write('</>\n')
20503  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
20504  CHAgp = (0.1/cal[0][1])+cal[1][0]
20505  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20506  CHAgn = (-0.1/cal[0][2])+cal[1][0]
20507  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
20508  CalFile.write('<>\n')
20509  CalFile.write('\n')
20510  # [2]
20511  CalFile.write('# Channel A, source V\n')
20512  CalFile.write('</>\n')
20513  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
20514  CHAgp = (5.0/cal[2][1])+cal[2][0]
20515  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20516  CalFile.write('<>\n')
20517  CalFile.write('\n')
20518  # [3]
20519  CalFile.write('# Channel A, source I\n')
20520  CalFile.write('</>\n')
20521  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
20522  CHAgp = (0.1/cal[3][1])+cal[3][0]
20523  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20524  CHAgn = (-0.1/cal[3][2])+cal[3][0]
20525  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20526  CalFile.write('<>\n')
20527  CalFile.write('\n')
20528  # [4]
20529  CalFile.write('# Channel B, measure V\n')
20530  CalFile.write('</>\n')
20531  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
20532  CHAgp = (5.0/cal[4][1])+cal[4][0]
20533  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20534  CalFile.write('<>\n')
20535  CalFile.write('\n')
20536  # [5]
20537  CalFile.write('# Channel B, measure I\n')
20538  CalFile.write('</>\n')
20539  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
20540  CHAgp = (0.1/cal[5][1])+cal[5][0]
20541  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20542  CHAgn = (-0.1/cal[5][2])+cal[5][0]
20543  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20544  CalFile.write('<>\n')
20545  CalFile.write('\n')
20546  # [6]
20547  CalFile.write('# Channel B, source V\n')
20548  CalFile.write('</>\n')
20549  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
20550  CHAgp = (5.0/cal[6][1])+cal[6][0]
20551  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20552  CalFile.write('<>\n')
20553  CalFile.write('\n')
20554  # [7]
20555  CalFile.write('# Channel B source I\n')
20556  CalFile.write('</>\n')
20557  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
20558  CHAgp = (0.1/cal[7][1])+cal[7][0]
20559  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20560  CHAgn = (-0.1/cal[7][2])+cal[7][0]
20561  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20562  CalFile.write('<>\n')
20563  #
20564  CalFile.close()
20565 
20567 def SPIShiftOut(DValue):
20568  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
20569 
20570  binstr = bin(DValue)
20571  binlen = len(binstr)
20572  datastr = binstr[2:binlen]
20573  datalen = len(datastr)
20574  if datalen < 16:
20575  datastr = str.rjust(datastr , 16 , '0')
20576  datalen = len(datastr)
20577  i = 1
20578  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
20579  while i < datalen+1:
20580  # sending 0x50 = set to 0, 0x51 = set to 1
20581  D1code = 0x50 + int(datastr[i-1])
20582  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
20583  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
20584  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
20585  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
20586  i = i + 1
20587  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
20588 #
20589 def SetAD9833(temp):
20590  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
20591  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
20592 
20593  #
20594  if MinigenScreenStatus.get() == 0:
20595  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
20596  #etssrlab.config(text=SRstring)
20597  return
20598  #
20599  if EnableMinigenMode == 2:
20600  MinigenMode.set(40)
20601  #
20602  try:
20603  FminE = float(eval(FminEntry.get()))*1000
20604  except:
20605  if EnableHSsampling > 0:
20606  FminEntry.delete(0,END)
20607  FminEntry.insert(0, FminE/1000)
20608  if MulX == 1:
20609  Fmin = FminE
20610  else:
20611  Fmin = FminE - (FminE/MulX)
20612  #
20613  MinigenFout.delete(0,"end")
20614  MinigenFout.insert(0,Fmin)
20615  #
20616  BSendMG()
20617 
20619 def BSendMG():
20620  global MinigenFclk, MinigenFout, MinigenMode
20621  global Two28, SCLKPort, SDATAPort, SLATCHPort
20622 
20623  DValue = 8192 + MinigenMode.get()
20624  SPIShiftOut(DValue)
20625  try:
20626  fout = float(eval(MinigenFout.get()))
20627  except:
20628  MinigenFout.delete(0,"end")
20629  MinigenFout.insert(0,100)
20630  try:
20631  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
20632  except:
20633  MingenFclk.delete(0,"end")
20634  MinigenFclk.insert(0,16)
20635  Freg = int((fout*Two28)/mclk)
20636  Foutstr = bin(Freg)
20637  Foutlen = len(Foutstr)
20638  datastr = Foutstr[2:Foutlen]
20639  datalen = len(datastr)
20640  if datalen < 28:
20641  datastr = str.rjust(datastr , 28 , '0')
20642  datalen = len(datastr)
20643  Fmsb = '0b01' + datastr[0:14]
20644  Flsb = '0b01' + datastr[14:]
20645  FValue = int(eval(Flsb))
20646  SPIShiftOut(FValue)
20647  FValue = int(eval(Fmsb))
20648  SPIShiftOut(FValue)
20649 
20652  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
20653  global SCLKPort, SDATAPort, SLATCHPort
20654  global GenericSerialStatus
20655  global PIO_0, PIO_1, PIO_2, PIO_3
20656 
20657  if GenericSerialStatus.get() == 1:
20658  GenericSerialStatus.set(0)
20660  if MinigenScreenStatus.get() == 0:
20661  MinigenScreenStatus.set(1)
20662  minigenwindow = Toplevel()
20663  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
20664  minigenwindow.resizable(FALSE,FALSE)
20665  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
20666  #
20667  MinigenMode = IntVar(0)
20668  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
20669  mgb1.grid(row=1, column=0, sticky=W)
20670  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
20671  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
20672  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
20673  mgb3.grid(row=2, column=0, sticky=W)
20674  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
20675  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
20676  f0lab = Label(minigenwindow, text="Mclk in MHz")
20677  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
20678  MinigenFclk = Entry(minigenwindow, width=5)
20679  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
20680  MinigenFclk.delete(0,"end")
20681  MinigenFclk.insert(0,16)
20682  f1lab = Label(minigenwindow, text="Output Freq")
20683  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
20684  MinigenFout = Entry(minigenwindow, width=8, cursor='double_arrow')
20685  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
20686  MinigenFout.bind("<Button-4>", onMiniGenScroll)# with Linux OS
20687  MinigenFout.bind("<Button-5>", onMiniGenScroll)
20688  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
20689  MinigenFout.delete(0,"end")
20690  MinigenFout.insert(0,100)
20691  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
20692  bsn1.grid(row=5, column=0, sticky=W, pady=4)
20693  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
20694  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
20695  #
20696  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
20697  label3.grid(row=6, column=0, sticky=W)
20698  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
20699  sclk1.grid(row=6, column=1, sticky=W)
20700  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
20701  sclk2.grid(row=6, column=2, sticky=W)
20702  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
20703  sclk3.grid(row=6, column=3, sticky=W)
20704  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
20705  sclk4.grid(row=6, column=4, sticky=W)
20706  #
20707  label4 = Label(minigenwindow,text="SData PI/O Port ")
20708  label4.grid(row=7, column=0, sticky=W)
20709  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
20710  sdat1.grid(row=7, column=1, sticky=W)
20711  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
20712  sdat2.grid(row=7, column=2, sticky=W)
20713  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
20714  sdat3.grid(row=7, column=3, sticky=W)
20715  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
20716  sdat4.grid(row=7, column=4, sticky=W)
20717  #
20718  label5 = Label(minigenwindow,text="FSync PI/O Port ")
20719  label5.grid(row=8, column=0, sticky=W)
20720  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
20721  slth1.grid(row=8, column=1, sticky=W)
20722  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
20723  slth2.grid(row=8, column=2, sticky=W)
20724  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
20725  slth3.grid(row=8, column=3, sticky=W)
20726  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
20727  slth4.grid(row=8, column=4, sticky=W)
20728  #
20729 
20732  global minigenwindow, MinigenScreenStatus
20733 
20734  MinigenScreenStatus.set(0)
20735  minigenwindow.destroy()
20736 #
20737 def onMiniGenScroll(event):
20738  global ETSStatus, ETSDisp
20739 
20740  onTextScroll(event)
20741  BSendMG()
20742 
20744 def DA1ShiftOut(D1Value, D2Value):
20745  global devx
20746  global PIO_0, PIO_1, PIO_2, PIO_3
20747 
20748  binstr = bin(D1Value)
20749  binlen = len(binstr)
20750  data1str = binstr[2:binlen]
20751  datalen = len(data1str)
20752  if datalen < 16:
20753  data1str = str.rjust(data1str , 16 , '0')
20754  datalen = len(data1str)
20755  #
20756  binstr = bin(D2Value)
20757  binlen = len(binstr)
20758  data2str = binstr[2:binlen]
20759  datalen = len(data2str)
20760  if datalen < 16:
20761  data2str = str.rjust(data2str , 16 , '0')
20762  datalen = len(data2str)
20763  # sync --> PIO 0
20764  # D0 --> PIO 1
20765  # D1 --> PIO 2
20766  # SCLK --> PIO 3
20767  i = 1
20768 #
20769  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
20770  while i < datalen+1:
20771  # sending 0x50 = set to 0, 0x51 = set to 1
20772  D1code = 0x50 + int(data1str[i-1])
20773  D2code = 0x50 + int(data2str[i-1])
20774  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
20775  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
20776  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
20777  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
20778  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
20779  i = i + 1
20780  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
20781  #
20782 def BSendDA1():
20783  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
20784 
20785  try:
20786  RefValue = float(eval(REFEntry.get()))
20787  except:
20788  RefValue = 3.3
20789  try:
20790  D1Value = float(eval(DAC1Entry.get()))
20791  except:
20792  D1Value = 0.0129
20793  D1Code = int((D1Value/RefValue)*255)
20794  if D1Code > 255:
20795  D1Code = 255
20796  D1Code = D1Code + 0x2000
20797  try:
20798  D2Value = float(eval(DAC2Entry.get()))
20799  except:
20800  D2Value = 0.0129
20801  D2Code = int((D2Value/RefValue)*255)
20802  if D2Code > 255:
20803  D2Code = 255
20804  D2Code = D2Code + 0x2400
20805  try:
20806  D3Value = float(eval(DAC3Entry.get()))
20807  except:
20808  D3Value = 0.0129
20809  D3Code = int((D3Value/RefValue)*255)
20810  if D3Code > 255:
20811  D3Code = 255
20812  D3Code = D3Code + 0x2000
20813  try:
20814  D4Value = float(eval(DAC4Entry.get()))
20815  except:
20816  D4Value = 0.0129
20817  D4Code = int((D4Value/RefValue)*255)
20818  if D4Code > 255:
20819  D4Code = 255
20820  D4Code = D4Code + 0x2400
20821  #
20822  DA1ShiftOut(D1Code, D3Code)
20823  DA1ShiftOut(D2Code, D4Code)
20824 
20827  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
20828  global REFEntry, RevDate, SWRev
20829 
20830  if DA1ScreenStatus.get() == 0:
20831  DA1ScreenStatus.set(1)
20832  da1window = Toplevel()
20833  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
20834  da1window.resizable(FALSE,FALSE)
20835  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
20836 #
20837  d1lab = Label(da1window, text="DAC A1 output")
20838  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
20839  DAC1Entry = Entry(da1window, width=5)
20840  DAC1Entry.grid(row=0, column=1, sticky=W)
20841  DAC1Entry.delete(0,"end")
20842  DAC1Entry.insert(0,0)
20843  d2lab = Label(da1window, text="DAC B1 output")
20844  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
20845  DAC2Entry = Entry(da1window, width=5)
20846  DAC2Entry.grid(row=1, column=1, sticky=W)
20847  DAC2Entry.delete(0,"end")
20848  DAC2Entry.insert(0,0)
20849 
20850  d3lab = Label(da1window, text="DAC A2 output")
20851  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
20852  DAC3Entry = Entry(da1window, width=5)
20853  DAC3Entry.grid(row=2, column=1, sticky=W)
20854  DAC3Entry.delete(0,"end")
20855  DAC3Entry.insert(0,0)
20856 
20857  d4lab = Label(da1window, text="DAC B2 output")
20858  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
20859  DAC4Entry = Entry(da1window, width=5)
20860  DAC4Entry.grid(row=3, column=1, sticky=W)
20861  DAC4Entry.delete(0,"end")
20862  DAC4Entry.insert(0,0)
20863 
20864  d5lab = Label(da1window, text="Reference V")
20865  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
20866  REFEntry = Entry(da1window, width=5)
20867  REFEntry.grid(row=4, column=1, sticky=W)
20868  REFEntry.delete(0,"end")
20869  REFEntry.insert(0,3.3)
20870 
20871  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
20872  bsn1.grid(row=5, column=0, sticky=W)
20873  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
20874  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
20875 
20878  global da1window, DA1ScreenStatus
20879 
20880  DA1ScreenStatus.set(0)
20881  da1window.destroy()
20882 
20883 def DigPotShiftOut(DValue):
20884  global devx, SingleDualPot
20885  global PIO_0, PIO_1, PIO_2, PIO_3
20886 
20887  binstr = bin(DValue)
20888  binlen = len(binstr)
20889  datastr = binstr[2:binlen]
20890  datalen = len(datastr)
20891  if SingleDualPot.get() == 0: # send 10 bits of data
20892  if datalen < 10:
20893  datastr = str.rjust(datastr , 10 , '0')
20894  datalen = len(datastr)
20895  if SingleDualPot.get() == 1: # send 8 bits of data
20896  if datalen < 8:
20897  datastr = str.rjust(datastr , 8 , '0')
20898  datalen = len(datastr)
20899  if SingleDualPot.get() == 2: # send 8 bits of data
20900  if datalen < 8:
20901  datastr = str.rjust(datastr , 8 , '0')
20902  datalen = len(datastr)
20903  i = 1
20904  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
20905  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
20906  while i < datalen+1:
20907  # CS --> PIO 0
20908  # D0 --> PIO 1
20909  # D1 --> PIO 2
20910  # SCLK --> PIO 3
20911  D1code = 0x50 + int(datastr[i-1])
20912  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
20913  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
20914  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
20915  i = i + 1
20916  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
20917  #
20918 def DigPotSend(Temp):
20919  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
20920  global SingleDualPot
20921 
20922  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
20923  NumTaps = 255
20924  if SingleDualPot.get() == 2:
20925  NumTaps = 63
20926  try:
20927  DValue1 = DigPot1.get()
20928  if DValue1 > NumTaps:
20929  DValue1 = NumTaps
20930  except:
20931  DValue1 = 0
20932  try:
20933  DValue2 = DigPot2.get()
20934  if DValue2 > NumTaps:
20935  DValue2 = NumTaps
20936  except:
20937  DValue2 = 0
20938  try:
20939  DValue3 = DigPot3.get()
20940  if DValue3 > NumTaps:
20941  DValue3 = NumTaps
20942  except:
20943  DValue3 = 0
20944  try:
20945  DValue4 = DigPot4.get()
20946  if DValue4 > NumTaps:
20947  DValue4 = NumTaps
20948  except:
20949  DValue4 = 0
20950  if SendPot1.get() > 0:
20951  DigPotShiftOut(DValue1)
20952  if SendPot2.get() > 0:
20953  DigPotShiftOut(DValue2+NumTaps+1)
20954  if SendPot3.get() > 0:
20955  DigPotShiftOut(DValue3+2*(NumTaps+1))
20956  if SendPot4.get() > 0:
20957  DigPotShiftOut(DValue4+3*(NumTaps+1))
20958 
20960  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
20961 
20962  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
20963  DPotlabel.config(text="Enter number from 0 to 255")
20964  DigPot1.config(from_=0, to=255, length=256)
20965  DigPot2.config(from_=0, to=255, length=256)
20966  DigPot3.config(from_=0, to=255, length=256)
20967  DigPot4.config(from_=0, to=255, length=256)
20968  if SingleDualPot.get() == 2:
20969  DPotlabel.config(text="Enter number from 0 to 63")
20970  DigPot1.config(from_=0, to=63, length=64)
20971  DigPot2.config(from_=0, to=63, length=64)
20972  DigPot3.config(from_=0, to=63, length=64)
20973  DigPot4.config(from_=0, to=63, length=64)
20974 
20977  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
20978  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
20979  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
20980 
20981  if DigPotScreenStatus.get() == 0:
20982  DigPotScreenStatus.set(1)
20983  digpotwindow = Toplevel()
20984  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
20985  digpotwindow.resizable(FALSE,FALSE)
20986  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
20987  #
20988  SendPot1 = IntVar(0)
20989  SendPot1.set(1)
20990  SendPot2 = IntVar(0)
20991  SendPot2.set(1)
20992  SendPot3 = IntVar(0)
20993  SendPot3.set(0)
20994  SendPot4 = IntVar(0)
20995  SendPot4.set(0)
20996  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
20997  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
20998 
20999  SingleDualPot = IntVar(0)
21000  SingleDualPot.set(0)
21001  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
21002  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
21003  CompMenu["menu"] = CompMenu.menu
21004  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
21005  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
21006  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
21007  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
21008  lab1 = Checkbutton(digpotwindow,text="Pot 1", variable=SendPot1)
21009  lab1.grid(row=2, column=0, sticky=W)
21010  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21011  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
21012  lab2 = Checkbutton(digpotwindow,text="Pot 2", variable=SendPot2)
21013  lab2.grid(row=4, column=0, sticky=W)
21014  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21015  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
21016  lab3 = Checkbutton(digpotwindow,text="Pot 3", variable=SendPot3)
21017  lab3.grid(row=6, column=0, sticky=W)
21018  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21019  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
21020  lab4 = Checkbutton(digpotwindow,text="Pot 4", variable=SendPot4)
21021  lab4.grid(row=8, column=0, sticky=W)
21022  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21023  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
21024  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
21025  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
21026 
21028  global digpotwindow, DigPotScreenStatus
21029 
21030  DigPotScreenStatus.set(0)
21031  digpotwindow.destroy()
21032 
21033 def BSendGS():
21034  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21035  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
21036 
21037  if AD5626SerialStatus.get() == 0:
21038  try:
21039  DValue = int(eval(DataBitsEntry.get()))
21040  if DValue < 0:
21041  DValue = 0
21042  except:
21043  DValue = 0
21044  try:
21045  NumBits = int(NumBitsEntry.get())
21046  if NumBits < 1:
21047  NumBits = 1
21048  except:
21049  NumBits = 8
21050  else:
21051  try:
21052  DValue = int(eval(AD5626Entry.get())*1000)
21053  if DValue < 0:
21054  DValue = 0
21055  AD5626Entry.delete(0,"end")
21056  AD5626Entry.insert(0,'0.000')
21057  if DValue > 4095:
21058  DValue = 4095
21059  AD5626Entry.delete(0,"end")
21060  AD5626Entry.insert(0,DValue/1000.0)
21061  except:
21062  DValue = 0
21063  AD5626Entry.delete(0,"end")
21064  AD5626Entry.insert(0,'0.000')
21065  NumBits = 12
21066  # print DValue
21067  binstr = bin(DValue)
21068  binlen = len(binstr)
21069  datastr = binstr[2:binlen]
21070  datalen = len(datastr)
21071  if datalen < NumBits:
21072  datastr = str.rjust(datastr , NumBits , '0')
21073  datalen = len(datastr)
21074  if SLatchPhase.get() == 0:
21075  LatchInt = 0x50
21076  LatchEnd = 0x51
21077  else:
21078  LatchInt = 0x51
21079  LatchEnd = 0x50
21080  if AD5626SerialStatus.get() > 0:
21081  LatchInt = 0x51
21082  LatchEnd = 0x50
21083  if SClockPhase.get() == 0:
21084  ClockInt = 0x50
21085  ClockEnd = 0x51
21086  else:
21087  ClockInt = 0x51
21088  ClockEnd = 0x50
21089  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21090  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21091  i = 1
21092  while i < datalen+1:
21093  if SerDirection.get() == 1: # for MSB first
21094  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
21095  else:
21096  D1code = 0x50 + int(datastr[i-1]) # for LSB first
21097  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
21098  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21099  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21100  i = i + 1
21101  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21102  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21103  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21104  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21105 
21108  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21109  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
21110  global PIO_0, PIO_1, PIO_2, PIO_3
21111 
21112  if GenericSerialStatus.get() == 1:
21113  GenericSerialStatus.set(0)
21115  if AD5626SerialStatus.get() == 0:
21116  AD5626SerialStatus.set(1)
21117  ad5626window = Toplevel()
21118  ad5626window.title("AD5626 Output " + SWRev + RevDate)
21119  ad5626window.resizable(FALSE,FALSE)
21120  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
21121 #
21122  SLatchPhase = IntVar(0)
21123  SLatchPhase.set(0)
21124  SClockPhase = IntVar(0)
21125  SClockPhase.set(1)
21126  SerDirection = IntVar(0)
21127  SerDirection.set(0)
21128  #
21129  label2 = Label(ad5626window,text="Enter Output Volts")
21130  label2.grid(row=1, column=0, columnspan=1, sticky=W)
21131  AD5626Entry = Entry(ad5626window, width=10, cursor='double_arrow')
21132  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
21133  AD5626Entry.bind("<Button-4>", onAD5626Scroll)# with Linux OS
21134  AD5626Entry.bind("<Button-5>", onAD5626Scroll)
21135  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
21136  AD5626Entry.delete(0,"end")
21137  AD5626Entry.insert(0,'0.000')
21138  #
21139  label3 = Label(ad5626window,text="SCLK PI/O Port ")
21140  label3.grid(row=2, column=0, columnspan=1, sticky=W)
21141  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
21142  sclk1.grid(row=2, column=1, sticky=W)
21143  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
21144  sclk2.grid(row=2, column=2, sticky=W)
21145  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
21146  sclk3.grid(row=2, column=3, sticky=W)
21147  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
21148  sclk4.grid(row=2, column=4, sticky=W)
21149  #
21150  label4 = Label(ad5626window,text="SData PI/O Port ")
21151  label4.grid(row=3, column=0, columnspan=1, sticky=W)
21152  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
21153  sdat1.grid(row=3, column=1, sticky=W)
21154  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
21155  sdat2.grid(row=3, column=2, sticky=W)
21156  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
21157  sdat3.grid(row=3, column=3, sticky=W)
21158  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
21159  sdat4.grid(row=3, column=4, sticky=W)
21160  #
21161  label5 = Label(ad5626window,text="Latch PI/O Port ")
21162  label5.grid(row=4, column=0, columnspan=1, sticky=W)
21163  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
21164  slth1.grid(row=4, column=1, sticky=W)
21165  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
21166  slth2.grid(row=4, column=2, sticky=W)
21167  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
21168  slth3.grid(row=4, column=3, sticky=W)
21169  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
21170  slth4.grid(row=4, column=4, sticky=W)
21171  #
21172  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
21173  bsn1.grid(row=5, column=0, sticky=W)
21174  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
21175  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
21176 #
21177 def onAD5626Scroll(event):
21178  onTextScroll(event)
21179  BSendGS()
21180 
21182  global ad5626window, AD5626SerialStatus
21183 
21184  AD5626SerialStatus.set(0)
21185  ad5626window.destroy()
21186 
21188  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21189  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
21190  global PIO_0, PIO_1, PIO_2, PIO_3
21191 
21192  if GenericSerialStatus.get() == 0:
21193  GenericSerialStatus.set(1)
21194  serialwindow = Toplevel()
21195  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
21196  serialwindow.resizable(FALSE,FALSE)
21197  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
21198  #
21199  SCLKPort = IntVar(0)
21200  SCLKPort.set(PIO_2)
21201  SDATAPort = IntVar(0)
21202  SDATAPort.set(PIO_1)
21203  SLATCHPort = IntVar(0)
21204  SLATCHPort.set(PIO_0)
21205  SLatchPhase = IntVar(0)
21206  SClockPhase = IntVar(0)
21207  SerDirection = IntVar(0)
21208  label = Label(serialwindow,text="Enter number of Bits")
21209  label.grid(row=1, column=0, columnspan=2, sticky=W)
21210  NumBitsEntry = Entry(serialwindow, width=3)
21211  NumBitsEntry.grid(row=1, column=2, sticky=W)
21212  NumBitsEntry.delete(0,"end")
21213  NumBitsEntry.insert(0,8)
21214  #
21215  label2 = Label(serialwindow,text="Enter Data Word")
21216  label2.grid(row=2, column=0, columnspan=1, sticky=W)
21217  DataBitsEntry = Entry(serialwindow, width=10)
21218  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
21219  DataBitsEntry.delete(0,"end")
21220  DataBitsEntry.insert(0,0)
21221  #
21222  label3 = Label(serialwindow,text="SCLK PI/O Port ")
21223  label3.grid(row=3, column=0, columnspan=1, sticky=W)
21224  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
21225  sclk1.grid(row=3, column=1, sticky=W)
21226  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
21227  sclk2.grid(row=3, column=2, sticky=W)
21228  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
21229  sclk3.grid(row=3, column=3, sticky=W)
21230  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
21231  sclk4.grid(row=3, column=4, sticky=W)
21232  #
21233  label4 = Label(serialwindow,text="SData PI/O Port ")
21234  label4.grid(row=4, column=0, columnspan=1, sticky=W)
21235  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
21236  sdat1.grid(row=4, column=1, sticky=W)
21237  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
21238  sdat2.grid(row=4, column=2, sticky=W)
21239  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
21240  sdat3.grid(row=4, column=3, sticky=W)
21241  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
21242  sdat4.grid(row=4, column=4, sticky=W)
21243  #
21244  label5 = Label(serialwindow,text="Latch PI/O Port ")
21245  label5.grid(row=5, column=0, columnspan=1, sticky=W)
21246  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
21247  slth1.grid(row=5, column=1, sticky=W)
21248  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
21249  slth2.grid(row=5, column=2, sticky=W)
21250  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
21251  slth3.grid(row=5, column=3, sticky=W)
21252  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
21253  slth4.grid(row=5, column=4, sticky=W)
21254  #
21255  label6 = Label(serialwindow,text="Latch Phase ")
21256  label6.grid(row=6, column=0, columnspan=1, sticky=W)
21257  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
21258  sph1.grid(row=6, column=1, sticky=W)
21259  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
21260  sph2.grid(row=6, column=2, sticky=W)
21261  #
21262  label7 = Label(serialwindow,text="Clock Phase ")
21263  label7.grid(row=7, column=0, columnspan=1, sticky=W)
21264  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
21265  sph7.grid(row=7, column=1, sticky=W)
21266  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
21267  sph8.grid(row=7, column=2, sticky=W)
21268  #
21269  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
21270  sdir1.grid(row=8, column=0, sticky=W)
21271  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
21272  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
21273 
21274  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
21275  bsn1.grid(row=9, column=0, sticky=W)
21276  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
21277  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
21278 
21280  global serialwindow, GenericSerialStatus
21281 
21282  GenericSerialStatus.set(0)
21283  serialwindow.destroy()
21284 
21287  global digfltwindow, DigFiltStatus, RevDate, SWRev, DeBugMode
21288  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
21289  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
21290  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
21291  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, AWGFiltAFile
21292  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength, AWGFiltBFile
21293 
21294  if DigFiltStatus.get() == 0:
21295  DigFiltStatus.set(1)
21296  digfltwindow = Toplevel()
21297  digfltwindow.title("Digital Filter " + SWRev + RevDate)
21298  digfltwindow.resizable(FALSE,FALSE)
21299  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
21300  #
21301  scriptbutton = Button(digfltwindow, text="Run Script", style="W11.TButton", command=RunScript)
21302  scriptbutton.grid(row=0, column=0, columnspan=1, sticky=W)
21303  dismissdfbutton = Button(digfltwindow, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
21304  dismissdfbutton.grid(row=0, column=1, columnspan=1, sticky=W)
21305  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
21306  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
21307  #frame2.pack(side=LEFT, expand=1, fill=X)
21308  #frame3.pack(side=LEFT, expand=1, fill=X)
21309  frame2.grid(row=1, column=0, sticky=W)
21310  frame3.grid(row=1, column=1, sticky=W)
21311  frame4 = LabelFrame(digfltwindow, text="AWG A Filter", style="A10R1.TLabelframe")
21312  frame5 = LabelFrame(digfltwindow, text="AWG B Filter", style="A10R2.TLabelframe")
21313  frame4.grid(row=2, column=0, sticky=W)
21314  frame5.grid(row=2, column=1, sticky=W)
21315  #
21316  digfilta = Frame( frame2 )
21317  digfilta.pack(side=LEFT)
21318  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
21319  #titlab.grid(row=0, column=0, sticky=W)
21320  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
21321  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
21322  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
21323  lab3.grid(row=1, column=0, sticky=W)
21324  BCALenEntry = Entry(digfilta, width=3, cursor='double_arrow')
21325  BCALenEntry.bind("<Return>", onRetDigFiltA)
21326  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
21327  BCALenEntry.bind("<Button-4>", onDigFiltAScroll)# with Linux OS
21328  BCALenEntry.bind("<Button-5>", onDigFiltAScroll)
21329  # BCALenEntry.bind('<Key>', onTextKey)
21330  BCALenEntry.grid(row=1, column=1, sticky=W)
21331  BCALenEntry.delete(0,"end")
21332  BCALenEntry.insert(0,2)
21333  bcalab = Label(digfilta, text="Length")
21334  bcalab.grid(row=1, column=2, sticky=W)
21335  DifFiltALength = Label(digfilta, text="Length = 0 ")
21336  DifFiltALength.grid(row=2, column=0, sticky=W)
21337  DifFiltAFile = Label(digfilta, text="File Name, none ")
21338  DifFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
21339  cald = Button(digfilta, text='Load CH A Filter Coef', command=BLoadDFiltA)
21340  cald.grid(row=4, column=0, columnspan=3, sticky=W)
21341  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
21342  camath.grid(row=5, column=0, columnspan=3, sticky=W)
21343 
21344  # Deskew controls
21345  lab5 = Checkbutton(digfilta, text="DeSkew A", variable=DigDeSkewA)# , command=BuildBoxCarA)
21346  lab5.grid(row=6, column=0, sticky=W)
21347  BCASkewEntry = Entry(digfilta, width=3, cursor='double_arrow')
21348  BCASkewEntry.bind('<MouseWheel>', onTextScroll)
21349  BCASkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21350  BCASkewEntry.bind("<Button-5>", onTextScroll)
21351  BCASkewEntry.grid(row=6, column=1, sticky=W)
21352  BCASkewEntry.delete(0,"end")
21353  BCASkewEntry.insert(0,0)
21354  bcasklab = Label(digfilta, text="# Samples")
21355  bcasklab.grid(row=6, column=2, sticky=W)
21356  #
21357  #dismissdfbutton = Button(digfilta, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
21358  #dismissdfbutton.grid(row=7, column=0, columnspan=1, sticky=W)
21359  #
21360  digfiltb = Frame( frame3 )
21361  digfiltb.pack(side=RIGHT)
21362  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
21363  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
21364  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
21365  lab4.grid(row=1, column=0, sticky=W)
21366  BCBLenEntry = Entry(digfiltb, width=3, cursor='double_arrow')
21367  BCBLenEntry.bind("<Return>", onRetDigFiltB)
21368  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
21369  BCBLenEntry.bind("<Button-4>", onDigFiltBScroll)# with Linux OS
21370  BCBLenEntry.bind("<Button-5>", onDigFiltBScroll)
21371  # BCALenEntry.bind('<Key>', onTextKey)
21372  BCBLenEntry.grid(row=1, column=1, sticky=W)
21373  BCBLenEntry.delete(0,"end")
21374  BCBLenEntry.insert(0,2)
21375  bcblab = Label(digfiltb, text="Length")
21376  bcblab.grid(row=1, column=2, sticky=W)
21377  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
21378  DifFiltBLength.grid(row=2, column=0, sticky=W)
21379  DifFiltBFile = Label(digfiltb,text="File Name, none ")
21380  DifFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
21381  cbld = Button(digfiltb, text='Load CH B Filter Coef', command=BLoadDFiltB)
21382  cbld.grid(row=4, column=0, columnspan=3, sticky=W)
21383  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
21384  cbmath.grid(row=5, column=0, columnspan=3, sticky=W)
21385  # Deskew controls
21386  lab6 = Checkbutton(digfiltb,text="DeSkew B", variable=DigDeSkewB)# , command=BuildBoxCarA)
21387  lab6.grid(row=6, column=0, sticky=W)
21388  BCBSkewEntry = Entry(digfiltb, width=3, cursor='double_arrow')
21389  BCBSkewEntry.bind('<MouseWheel>', onTextScroll)
21390  BCBSkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21391  BCBSkewEntry.bind("<Button-5>", onTextScroll)
21392  BCBSkewEntry.grid(row=6, column=1, sticky=W)
21393  BCBSkewEntry.delete(0,"end")
21394  BCBSkewEntry.insert(0,0)
21395  bcbsklab = Label(digfiltb, text="# Samples")
21396  bcbsklab.grid(row=6, column=2, sticky=W)
21397  # AWG A controls
21398  awgfilta = Frame( frame4 )
21399  awgfilta.pack(side=LEFT)
21400  lab7 = Checkbutton(awgfilta,text="Filter AWG A", variable=AWGFiltA, command=ReMakeAWGwaves)
21401  lab7.grid(row=0, column=0, columnspan=2, sticky=W)
21402  lab8 = Checkbutton(awgfilta,text="Box Car", variable=AWGFiltABoxCar, command=BuildAWGBoxCarA)
21403  lab8.grid(row=1, column=0, sticky=W)
21404  AWGALenEntry = Entry(awgfilta, width=3, cursor='double_arrow')
21405  AWGALenEntry.bind("<Return>", onRetAWGFiltA)
21406  AWGALenEntry.bind('<MouseWheel>', onAWGFiltAScroll)
21407  AWGALenEntry.bind("<Button-4>", onAWGFiltAScroll)# with Linux OS
21408  AWGALenEntry.bind("<Button-5>", onAWGFiltAScroll)
21409  # BCALenEntry.bind('<Key>', onTextKey)
21410  AWGALenEntry.grid(row=1, column=1, sticky=W)
21411  AWGALenEntry.delete(0,"end")
21412  AWGALenEntry.insert(0,2)
21413  awgalab = Label(awgfilta, text="Length")
21414  awgalab.grid(row=1, column=2, sticky=W)
21415  AWGFiltALength = Label(awgfilta, text="Length = 0 ")
21416  AWGFiltALength.grid(row=2, column=0, sticky=W)
21417  AWGFiltAFile = Label(awgfilta, text="File Name, none ")
21418  AWGFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
21419  awgaload = Button(awgfilta, text='Load AWG A Filter Coef', command=BLoadAWGFiltA)
21420  awgaload.grid(row=4, column=0, columnspan=3, sticky=W)
21421  awgamath = Button(awgfilta, text='AWG A Filter formula', command=BAWGFiltAMath)
21422  awgamath.grid(row=5, column=0, columnspan=3, sticky=W)
21423  #
21424  # AWG B controls
21425  awgfiltb = Frame( frame5 )
21426  awgfiltb.pack(side=RIGHT)
21427  lab9 = Checkbutton(awgfiltb,text="Filter AWG B", variable=AWGFiltB, command=ReMakeAWGwaves)
21428  lab9.grid(row=0, column=0, columnspan=2, sticky=W)
21429  lab10 = Checkbutton(awgfiltb,text="Box Car", variable=AWGFiltBBoxCar, command=BuildAWGBoxCarB)
21430  lab10.grid(row=1, column=0, sticky=W)
21431  AWGBLenEntry = Entry(awgfiltb, width=3, cursor='double_arrow')
21432  AWGBLenEntry.bind("<Return>", onRetAWGFiltB)
21433  AWGBLenEntry.bind('<MouseWheel>', onAWGFiltBScroll)
21434  AWGBLenEntry.bind("<Button-4>", onAWGFiltBScroll)# with Linux OS
21435  AWGBLenEntry.bind("<Button-5>", onAWGFiltBScroll)
21436  # BCALenEntry.bind('<Key>', onTextKey)
21437  AWGBLenEntry.grid(row=1, column=1, sticky=W)
21438  AWGBLenEntry.delete(0,"end")
21439  AWGBLenEntry.insert(0,2)
21440  awgblab = Label(awgfiltb, text="Length")
21441  awgblab.grid(row=1, column=2, sticky=W)
21442  AWGFiltBLength = Label(awgfiltb, text="Length = 0 ")
21443  AWGFiltBLength.grid(row=2, column=0, sticky=W)
21444  AWGFiltBFile = Label(awgfiltb, text="File Name, none ")
21445  AWGFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
21446  awgbload = Button(awgfiltb, text='Load AWG B Filter Coef', command=BLoadAWGFiltB)
21447  awgbload.grid(row=4, column=0, columnspan=3, sticky=W)
21448  awgbmath = Button(awgfiltb, text='AWG B Filter formula', command=BAWGFiltBMath)
21449  awgbmath.grid(row=5, column=0, columnspan=3, sticky=W)
21450  #
21451 def onRetDigFiltA(event):
21452  BuildBoxCarA()
21453 
21454 def onDigFiltAScroll(event):
21455  onTextScroll(event)
21456  BuildBoxCarA()
21457 
21459  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
21460 
21461  if DigFiltABoxCar.get() == 0:
21462  return
21463 
21464  FLength = int(BCALenEntry.get())
21465  if FLength < 2:
21466  return
21467 
21468  DFiltACoef = [] # empty coef array
21469 
21470  for n in range(FLength):
21471  DFiltACoef.append(float(1.0/FLength))
21472 
21473  DFiltACoef = numpy.array(DFiltACoef)
21474  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21475 
21476 def onRetDigFiltB(event):
21477  BuildBoxCarB()
21478 
21479 def onDigFiltBScroll(event):
21480  onTextScroll(event)
21481  BuildBoxCarB()
21482 
21484  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
21485 
21486  if DigFiltBBoxCar.get() == 0:
21487  return
21488 
21489  FLength = int(BCBLenEntry.get())
21490  if FLength < 2:
21491  return
21492 
21493  DFiltBCoef = [] # empty coef array
21494 
21495  for n in range(FLength):
21496  DFiltBCoef.append(float(1.0/FLength))
21497 
21498  DFiltBCoef = numpy.array(DFiltBCoef)
21499  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21500 
21502  global digfltwindow, DigFiltStatus
21503 
21504  DigFiltStatus.set(0)
21505  digfltwindow.destroy()
21506 
21508  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
21509 
21510 # Read values from CVS file
21511  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21512  try:
21513  CSVFile = open(filename)
21514  csv_f = csv.reader(CSVFile)
21515  except:
21516  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21517  return
21518  DFiltACoef = []
21519 
21520  for row in csv_f:
21521  try:
21522  DFiltACoef.append(float(row[0]))
21523  except:
21524  print( 'skipping non-numeric row')
21525  DFiltACoef = numpy.array(DFiltACoef)
21526  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21527  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21528  CSVFile.close()
21529 #
21531  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
21532 
21533  TempString = DigFilterAString
21534  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
21535  if (DigFilterAString == None): # If Cancel pressed, then None
21536  DigFilterAString = TempString
21537  return
21538  DFiltACoef = eval(DigFilterAString)
21539  DFiltACoef = numpy.array(DFiltACoef)
21540  coefsum = numpy.sum(DFiltACoef)
21541  DFiltACoef = DFiltACoef / coefsum # always normalize to a gain of one
21542  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21543  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
21544 
21546  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
21547 
21548 # Read values from CVS file
21549  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21550  try:
21551  CSVFile = open(filename)
21552  csv_f = csv.reader(CSVFile)
21553  except:
21554  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21555  return
21556  DFiltBCoef = []
21557 
21558  for row in csv_f:
21559  try:
21560  DFiltBCoef.append(float(row[0]))
21561  except:
21562  print( 'skipping non-numeric row')
21563  DFiltBCoef = numpy.array(DFiltBCoef)
21564  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21565  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21566  CSVFile.close()
21567 #
21569  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
21570 
21571  TempString = DigFilterBString
21572  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
21573  if (DigFilterBString == None): # If Cancel pressed, then None
21574  DigFilterBString = TempString
21575  return
21576  DFiltBCoef = eval(DigFilterBString)
21577  DFiltBCoef = numpy.array(DFiltBCoef)
21578  coefsum = numpy.sum(DFiltBCoef)
21579  DFiltBCoef = DFiltBCoef / coefsum
21580  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21581  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
21582 #
21583 def onRetAWGFiltA(event):
21584  BuildAWGBoxCarA()
21585 
21586 def onAWGFiltAScroll(event):
21587  onTextScroll(event)
21588  BuildAWGBoxCarA()
21589 
21591  global AWGALenEntry, AWGFiltACoef, AWGFiltABoxCar, AWGFiltALength
21592 
21593  if AWGFiltABoxCar.get() == 0:
21594  return
21595 
21596  FLength = int(AWGALenEntry.get())
21597  if FLength < 2:
21598  return
21599 
21600  AWGFiltACoef = [] # empty coef array
21601 
21602  for n in range(FLength):
21603  AWGFiltACoef.append(float(1.0/FLength))
21604 
21605  AWGFiltACoef = numpy.array(AWGFiltACoef)
21606  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21607  ReMakeAWGwaves()
21608 #
21609 def onRetAWGFiltB(event):
21610  BuildAWGBoxCarb()
21611 
21612 def onAWGFiltBScroll(event):
21613  onTextScroll(event)
21614  BuildAWGBoxCarB()
21615 
21617  global AWGBLenEntry, AWGFiltBCoef, AWGFiltBBoxCar, AWGFiltBLength
21618 
21619  if AWGFiltBBoxCar.get() == 0:
21620  return
21621 
21622  FLength = int(AWGBLenEntry.get())
21623  if FLength < 2:
21624  return
21625 
21626  AWGFiltBCoef = [] # empty coef array
21627 
21628  for n in range(FLength):
21629  AWGFiltBCoef.append(float(1.0/FLength))
21630 
21631  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21632  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21633  ReMakeAWGwaves()
21634 #
21636  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile
21637 
21638 # Read values from CVS file
21639  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21640  try:
21641  CSVFile = open(filename)
21642  csv_f = csv.reader(CSVFile)
21643  except:
21644  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21645  return
21646  AWGFiltACoef = []
21647 
21648  for row in csv_f:
21649  try:
21650  AWGFiltACoef.append(float(row[0]))
21651  except:
21652  print( 'skipping non-numeric row')
21653  AWGFiltACoef = numpy.array(AWGFiltACoef)
21654  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21655  AWGFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21656  CSVFile.close()
21657  ReMakeAWGwaves()
21658 #
21660  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile, AWGFilterAString
21661 
21662  TempString = AWGFilterAString
21663  AWGFilterAString = askstring("AWG A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=AWGFilterAString, parent=digfltwindow)
21664  if (AWGFilterAString == None): # If Cancel pressed, then None
21665  AWGFilterAString = TempString
21666  return
21667  AWGFiltACoef = eval(AWGFilterAString)
21668  AWGFiltACoef = numpy.array(AWGFiltACoef)
21669  coefsum = numpy.sum(AWGFiltACoef)
21670  AWGFiltACoef = AWGFiltACoef / coefsum
21671  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21672  AWGFiltAFile.config(text = "AWG A Filter formula" ) # change displayed file name
21673  ReMakeAWGwaves()
21674 #
21675 #
21677  global AWGFiltBCoef, digfltwindow, AWGFiltbLength, AWGFiltBFile
21678 
21679 # Read values from CVS file
21680  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21681  try:
21682  CSVFile = open(filename)
21683  csv_f = csv.reader(CSVFile)
21684  except:
21685  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21686  return
21687  AWGFiltBCoef = []
21688 
21689  for row in csv_f:
21690  try:
21691  AWGFiltBCoef.append(float(row[0]))
21692  except:
21693  print( 'skipping non-numeric row')
21694  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21695  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21696  AWGFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21697  CSVFile.close()
21698  ReMakeAWGwaves()
21699 #
21701  global AWGFiltBCoef, digfltwindow, AWGFiltBLength, AWGFiltBFile, AWGFilterBString
21702 
21703  TempString = AWGFilterBString
21704  AWGFilterBString = askstring("AWG B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=AWGFilterBString, parent=digfltwindow)
21705  if (AWGFilterBString == None): # If Cancel pressed, then None
21706  AWGFilterBString = TempString
21707  return
21708  AWGFiltBCoef = eval(AWGFilterBString)
21709  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21710  coefsum = numpy.sum(AWGFiltBCoef)
21711  AWGFiltBCoef = AWGFiltBCoef / coefsum
21712  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21713  AWGFiltBFile.config(text = "AWG B Filter formula" ) # change displayed file name
21714  ReMakeAWGwaves()
21715 #
21716 # Higher order SINC filters can be generated by convolving first order Box Car filters
21717 def BuildRejectFilter(Order, Freject, Fsample):
21718  # Order can be 1, 2, 3 or 4
21719  # Fsample = 100000
21720  # Calculate SINC1 oversample ratios for Freject
21721  osr = int(Fsample/Freject) #
21722  # osr60 = int(Fsample/60) # 60 Hz example
21723  # Create "boxcar" SINC1 filter
21724  sinc1 = numpy.ones(osr)
21725  # sinc1_60 = np.ones(osr60)
21726  # Calculate higher order filters
21727  sinc2 = numpy.convolve(sinc1, sinc1)
21728  sinc3 = numpy.convolve(sinc2, sinc1)
21729  sinc4 = numpy.convolve(sinc2, sinc2)
21730  fosr = float(Fsample/Freject)
21731  if Order == 1:
21732  return sinc1/fosr
21733  elif Order == 2:
21734  return sinc2/fosr
21735  elif Order == 3:
21736  return sinc3/fosr
21737  elif Order == 4:
21738  return sinc4/fosr
21739  else:
21740  return sinc1/fosr
21741  # Here's the SINC4-ish filter
21742  # with three zeros at 50Hz, one at 60Hz.
21743  # filt_50_60_rej = np.convolve(sinc3_50, sinc1_60)
21744 
21745 # Fit the function y = A * exp(B * x) to the data arrays xs and ys
21746 # returns (A, B)
21747 # From: https://mathworld.wolfram.com/LeastSquaresFittingExponential.html
21748 def fit_exp(xs, ys):
21749  S_x2_y = 0.0
21750  S_y_lny = 0.0
21751  S_x_y = 0.0
21752  S_x_y_lny = 0.0
21753  S_y = 0.0
21754  for (x,y) in zip(xs, ys):
21755  S_x2_y += x * x * y
21756  S_y_lny += y * numpy.log(y)
21757  S_x_y += x * y
21758  S_x_y_lny += x * y * numpy.log(y)
21759  S_y += y
21760  #end
21761  a = (S_x2_y * S_y_lny - S_x_y * S_x_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
21762  b = (S_y * S_x_y_lny - S_x_y * S_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
21763  return (numpy.exp(a), b)
21764 #
21766  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
21767 
21768  if CommandStatus.get() == 0:
21769  CommandStatus.set(1)
21770  commandwindow = Toplevel()
21771  commandwindow.title("Command Line " + SWRev + RevDate)
21772  commandwindow.resizable(FALSE,FALSE)
21773  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
21774  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
21775  toplab.grid(row=0, column=0, columnspan=4, sticky=W)
21776  cl1 = Label(commandwindow,text="Last command:")
21777  cl1.grid(row=1, column=0, sticky=W)
21778  LastCommand = Label(commandwindow,text=" ")
21779  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
21780  ExecString = Entry(commandwindow, width=40)
21781  ExecString.bind("<Return>", RExecuteFromString)
21782  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
21783  ExecString.delete(0,"end")
21784  ExecString.insert(0,"")
21785  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
21786  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
21787  scriptbutton = Button(commandwindow, text="Run Script", style="W10.TButton", command=RunScript)
21788  scriptbutton.grid(row=4, column=1, sticky=W, pady=8)
21789  #
21790  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
21791  dismissclbutton.grid(row=4, column=2, sticky=W, pady=7)
21792 
21794  global commandwindow, CommandStatus
21795 
21796  CommandStatus.set(0)
21797  commandwindow.destroy()
21798 
21800 
21802 
21803 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
21804  global ExecString, LastCommand
21805  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
21806  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
21807  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
21808  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
21809  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
21810  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
21811  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
21812  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
21813  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
21814  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
21815  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
21816  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
21817  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
21818  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
21819  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
21820  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
21821  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
21822  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
21823  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
21824  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
21825  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
21826  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
21827  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
21828  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
21829  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
21830  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
21831  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
21832  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
21833  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
21834  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
21835  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
21836  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
21837  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
21838  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
21839  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
21840  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
21841  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
21842  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
21843  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
21844  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
21845  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
21846  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
21847  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
21848  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
21849  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
21850  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
21851  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
21852  global phawindow, PhAca, PhAScreenStatus, PhADisp
21853  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
21854  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
21855  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
21856  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
21857  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
21858  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
21859  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
21860  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
21861  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
21862 
21863  try:
21864  exec( ExecString.get(), globals(), globals())
21865  # exec( ExecString.get() )
21866  LastCommand.config(text = ExecString.get() ) # change displayed last command
21867  except:
21868  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
21869  return()
21870 #
21871 def CAresize(event):
21872  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
21873 
21874  XOL = FontSize * 7
21875  CANVASwidth = event.width - 4
21876  CANVASheight = event.height - 4
21877  GRW = CANVASwidth - (2 * X0L) # new grid width
21878  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
21879  UpdateTimeAll()
21880 #
21882  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
21883  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
21884  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
21885  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
21886  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
21887  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
21888 
21889  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
21890  ChaValue1.config(text = ValueText)
21891  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
21892  ChaValue2.config(text = ValueText)
21893  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
21894  ChaValue3.config(text = ValueText)
21895  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
21896  ChaValue4.config(text = ValueText)
21897  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
21898  ChaValue5.config(text = ValueText)
21899  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
21900  ChaValue6.config(text = ValueText)
21901  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
21902  ChbValue1.config(text = ValueText)
21903  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
21904  ChbValue2.config(text = ValueText)
21905  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
21906  ChbValue3.config(text = ValueText)
21907  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
21908  ChbValue4.config(text = ValueText)
21909  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
21910  ChbValue5.config(text = ValueText)
21911  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
21912  ChbValue6.config(text = ValueText)
21913 #
21915  global measurewindow, MeasureStatus, RevDate, SWRev
21916  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
21917  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
21918  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
21919  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
21920  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
21921  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
21922 
21923  if MeasureStatus.get() == 0:
21924  MeasureStatus.set(1)
21925  measurewindow = Toplevel()
21926  measurewindow.title("Measurements " + SWRev + RevDate)
21927  measurewindow.resizable(FALSE,FALSE)
21928  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
21929  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
21930  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
21931  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
21932  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
21933  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21934  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
21935  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
21936  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
21937  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21938  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
21939  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
21940  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
21941  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21942  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
21943  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
21944  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
21945  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21946  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
21947  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
21948  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
21949  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21950  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
21951  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
21952  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
21953  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21954  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
21955  #
21956  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
21957  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
21958  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21959  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
21960  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
21961  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
21962  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21963  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
21964  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
21965  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
21966  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21967  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
21968  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
21969  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
21970  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21971  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
21972  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
21973  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
21974  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21975  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
21976  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
21977  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
21978  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21979  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
21980 #
21982  global measurewindow, MeasureStatus
21983 
21984  MeasureStatus.set(0)
21985  measurewindow.destroy()
21986 #
21988  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
21989  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
21990 
21991  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
21992  if BoardStatus.get() == 0:
21993  BoardStatus.set(1)
21994  boardwindow = Toplevel()
21995  boardwindow.title("Select Board " + RevDate)
21996  boardwindow.resizable(FALSE,FALSE)
21997  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
21998  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
21999  toplab.pack(side=TOP)
22000  for idx, devx in enumerate(session.devices):
22001  BrdText = "Board # " + str(idx)
22002  if idx == 0:
22003  devx.set_led(0b010) # LED.green
22004  FWRevOne = float(devx.fwver)
22005  HWRevOne = devx.hwver
22006  dev0 = devx #session.devices[0]
22007  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22008  elif idx == 1:
22009  devx.set_led(0b100) # LED.blue,
22010  FWRevTwo = float(devx.fwver)
22011  HWRevTwo = devx.hwver
22012  dev1 = devx #session.devices[1]
22013  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22014  elif idx == 2:
22015  devx.set_led(0b001) # LED.red,
22016  FWRevThree = float(devx.fwver)
22017  HWRevThree = devx.hwver
22018  dev2 = devx #session.devices[2]
22019  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22020  else:
22021  dev3 = session.devices[3]
22022  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22023  brd.pack(side=TOP)
22024  else:
22025  devx = session.devices[0]
22026  # devx.ignore_dataflow = True
22027  devx.set_led(0b010) # if only one board set LED.green
22028  try:
22029  FWRevOne = float(devx.fwver)
22030  HWRevOne = devx.hwver
22031  except:
22032  FWRevOne = "Before 2.06"
22033  HWRevOne = "?"
22034  dev0 = session.devices[0]
22035 #
22037  global boardwindow, BoardStatus
22038 
22039  BoardStatus.set(0)
22040  boardwindow.destroy()
22041 #
22043  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
22044  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
22045 
22046  if DevID == "No Device" or DevID == "m1k":
22047  #print("Request sample rate: " + str(SAMPLErate))
22048  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
22049  # session.add_all()
22050  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
22051  if not session.devices:
22052  print( 'No Device plugged IN!')
22053  DevID = "No Device"
22054  FWRevOne = 0.0
22055  HWRevOne = "?"
22056  bcon.configure(text="Recon", style="RConn.TButton")
22057  return
22058  session.configure(sample_rate=SAMPLErate)
22059  # print("Session sample rate: " + str(session.sample_rate))
22060  MakeBoardScreen()
22061  SelectBoard()
22062  bcon.configure(text="Conn", style="GConn.TButton")
22063  devx.set_adc_mux(0)
22064  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
22065  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
22066 
22070  session.start(0)
22071 #
22073  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
22074  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
22075  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
22076 
22077  if RUNstatus.get() == 1:
22078  BStop()
22079  print( "STOP")
22080 
22081  if BrdSel.get() == 0:
22082  try:
22083  session.remove(dev1)
22084  print( "Removing dev1")
22085  except:
22086  print( "Skipping dev1")
22087  try:
22088  session.remove(dev2)
22089  print( "Removing dev2")
22090  except:
22091  print( "Skipping dev2")
22092  session.add(dev0)
22093  devx = dev0
22094  #session.add(devx)
22095  if BrdSel.get() == 1:
22096  try:
22097  session.remove(dev0)
22098  print( "Removing dev0")
22099  except:
22100  print( "Skipping dev0")
22101  try:
22102  session.remove(dev2)
22103  print( "Removing dev2")
22104  except:
22105  print( "Skipping dev2")
22106  session.add(dev1)
22107  devx = dev1
22108  #session.add(devx)
22109  DevID = devx.serial
22110  print( DevID)
22111  FWRevOne = float(devx.fwver)
22112  HWRevOne = str(devx.hwver)
22113  print( FWRevOne, HWRevOne)
22114  # print("Session sample rate: " + str(session.sample_rate))
22115 
22116  if IgnoreFirmwareCheck == 0:
22117  if FWRevOne < 2.17:
22118  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
22119  UpdateFirmware()
22120  cal = devx.calibration
22121  CHA = devx.channels['A'] # Open CHA
22122  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
22123  CHB = devx.channels['B'] # Open CHB
22124  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
22125  #
22126  # if session.continuous == 0:
22127  #session.start(0)
22128 
22137  devx.set_adc_mux(0)
22138  if devx.hwver == "F":
22139  print( "Rev F Board I/O ports set")
22140  PIO_0 = 28
22141  PIO_1 = 29
22142  PIO_2 = 47
22143  PIO_3 = 3
22144  PIO_4 = 4
22145  PIO_5 = 5
22146  PIO_6 = 6
22147  PIO_7 = 7
22148  else:
22149  PIO_0 = 0
22150  PIO_1 = 1
22151  PIO_2 = 2
22152  PIO_3 = 3
22153  PIO_4 = 4
22154  PIO_5 = 5
22155  PIO_6 = 6
22156  PIO_7 = 7
22157 #
22158  SDATAPort.set(PIO_1)
22159  SCLKPort.set(PIO_2)
22160  SLATCHPort.set(PIO_0)
22161 
22163  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
22164  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
22165  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
22166  global FrameRefief, BorderSize
22167 
22168  if SampleRateStatus.get() == 0:
22169  SampleRateStatus.set(1)
22170  SampleRatewindow = Toplevel()
22171  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
22172  SampleRatewindow.resizable(FALSE,FALSE)
22173  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
22174  frame1 = Frame(SampleRatewindow, borderwidth=BorderSize, relief=FrameRefief)
22175  frame1.grid(row=0, column=0, sticky=W)
22176  #
22177  BaseRATE = Frame( frame1 )
22178  BaseRATE.grid(row=0, column=0, sticky=W)
22179  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
22180  baseratelab.pack(side=LEFT)
22181  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
22182  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
22183  BaseRatesb.bind("<Button-4>", onSrateScroll)# with Linux OS
22184  BaseRatesb.bind("<Button-5>", onSrateScroll)
22185  BaseRatesb.bind("<Return>", onRetSrate)
22186  BaseRatesb.pack(side=LEFT)
22187  BaseRatesb.delete(0,"end")
22188  BaseRatesb.insert(0,BaseSampleRate)
22189  #
22190  nextrow = 2
22191  if FWRevOne > 2.16:
22192  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
22193  twoX.grid(row=1, column=0, sticky=W)
22194  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
22195  muxlab1.grid(row=2, column=0, sticky=W)
22196  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
22197  AltSweep.grid(row=3, column=0, sticky=W)
22198  chabuttons = Frame( frame1 )
22199  chabuttons.grid(row=4, column=0, sticky=W)
22200  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
22201  muxrb1.pack(side=LEFT)
22202  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
22203  muxrb2.pack(side=LEFT)
22204  chcbuttons = Frame( frame1 )
22205  chcbuttons.grid(row=5, column=0, sticky=W)
22206  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
22207  muxrb5.pack(side=LEFT)
22208  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
22209  muxrb6.pack(side=LEFT)
22210  nextrow = 6
22211  if DeBugMode == 1:
22212  chbbuttons = Frame( frame1 )
22213  chbbuttons.grid(row=nextrow, column=0, sticky=W)
22214  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
22215  muxrb3.pack(side=LEFT)
22216  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
22217  muxrb4.pack(side=LEFT)
22218  nextrow = nextrow + 1
22219  #
22220  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
22221  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
22222 #
22224  global SampleRatewindow, SampleRateStatus
22225 
22226  SampleRateStatus.set(0)
22227  SampleRatewindow.destroy()
22228 #
22229 #
22230 def onSrateScroll(event):
22231 
22232  #onTextScroll
22233  onSpinBoxScroll(event)
22234  SetSampleRate()
22235 #
22236 def onRetSrate(event):
22237 
22238  SetSampleRate()
22239 #
22241  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
22242  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
22243 
22244  #
22245  WasRunning = 0
22246  if (RUNstatus.get() == 1):
22247  WasRunning = 1
22248  BStop() # Force Stop loop if running
22249  try:
22250  NewRate = int(BaseRatesb.get())
22251  if NewRate <= 100000: # rate has to be less than or equal to 100,000
22252  BaseSampleRate = NewRate
22253  else:
22254  BaseSampleRate = 100000
22255  BaseRatesb.delete(0,"end")
22256  BaseRatesb.insert(0,BaseSampleRate)
22257  SAMPLErate = BaseSampleRate # Scope sample rate
22258  except:
22259  donothing()
22260  session.configure(sample_rate=BaseSampleRate)
22261  BaseSampleRate = session.sample_rate
22262  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
22263  SAMPLErate = BaseSampleRate # Scope sample rate
22264  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
22265  AWGSAMPLErate = BaseSampleRate
22266  if ETSStatus.get() > 0:
22267  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
22268  rtsrlab.config(text=SRstring)
22269  ETSUpdate()
22270  BaseRatesb.delete(0,"end")
22271  BaseRatesb.insert(0,BaseSampleRate)
22272  ReMakeAWGwaves() # remake AWG waveforms for new rate
22273  if (WasRunning == 1):
22274  WasRunning = 0
22275  BStart() # restart loop if was running
22276 #
22277 def onStopfreqScroll(event):
22278  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
22279 
22280  onTextScroll(event)
22281  try:
22282  StopFrequency = float(StopFreqEntry.get())
22283  except:
22284  StopFreqEntry.delete(0,"end")
22285  StopFreqEntry.insert(0,50000)
22286  StopFrequency = 50000
22287  if FWRevOne > 2.16:
22288  if StopFrequency >= 50000:
22289  Two_X_Sample.set(1)
22290  ADC_Mux_Mode.set(0)
22291  SetADC_Mux()
22292  else:
22293  Two_X_Sample.set(0)
22294  ADC_Mux_Mode.set(0)
22295  SetADC_Mux()
22296 #
22297 def onStopBodeScroll(event):
22298  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
22299 
22300  onTextScroll(event)
22301  try:
22302  StopFrequency = float(StopBodeEntry.get())
22303  except:
22304  StopBodeEntry.delete(0,"end")
22305  StopBodeEntry.insert(0,20000)
22306  StopFrequency = 20000
22307  if FWRevOne > 2.16:
22308  if StopFrequency >= 20000:
22309  Two_X_Sample.set(1)
22310  ADC_Mux_Mode.set(0)
22311  SetADC_Mux()
22312  else:
22313  Two_X_Sample.set(0)
22314  ADC_Mux_Mode.set(0)
22315  SetADC_Mux()
22316 #
22318  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
22319  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
22320  global AWGSync, discontloop, session, ADsignal1
22321 
22322  if Two_X_Sample.get() == 1:
22323  if ADC_Mux_Mode.get() == 0: # VA and VB
22324  devx.set_adc_mux(1)
22325  elif ADC_Mux_Mode.get() == 1: # IA and IB
22326  devx.set_adc_mux(2)
22327  elif ADC_Mux_Mode.get() == 2: # VA and IB
22328  # cycle trhough default mux values as starting point
22329  devx.set_adc_mux(2)
22330  # now set new mux values
22331  devx.set_adc_mux(7)
22332  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
22333  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
22334  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
22335  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
22336  time.sleep(0.1)
22337  elif ADC_Mux_Mode.get() == 3: # VB and IA
22338  # cycle trhough default mux values as starting point
22339  # now set new mux values
22340  devx.set_adc_mux(7)
22341  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
22342  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
22343  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
22344  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
22345  time.sleep(0.1)
22346  elif ADC_Mux_Mode.get() == 4: # VA and IA
22347  # cycle trhough default mux values as starting point
22348  devx.set_adc_mux(2)
22349  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
22350  if discontloop > 0:
22351  session.flush()
22352  else:
22353  discontloop = 1
22354  time.sleep(0.01)
22355  BAWGEnab()
22356  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
22357 
22358  else: # running in continuous mode
22359  if session.continuous:
22360  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
22361  # now set new mux values
22362  devx.set_adc_mux(4)
22363  elif ADC_Mux_Mode.get() == 5: # VB and IB
22364  # cycle trhough default mux values as starting point
22365  devx.set_adc_mux(2)
22366  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
22367  if discontloop > 0:
22368  session.flush()
22369  else:
22370  discontloop = 1
22371  time.sleep(0.01)
22372  BAWGEnab()
22373  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
22374 
22375  else: # running in continuous mode
22376  if session.continuous:
22377  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
22378  # now set new mux values
22379  devx.set_adc_mux(5)
22380  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
22381  else:
22382  devx.set_adc_mux(0)
22383  SAMPLErate = BaseSampleRate
22384 #
22386  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
22387 
22388  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22389  ADC_Mux_Mode.set(0) # All four traces
22390  Alternate_Sweep_Mode.set(1)
22391  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
22392  ADC_Mux_Mode.set(0) # three traces
22393  Alternate_Sweep_Mode.set(1)
22394  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22395  ADC_Mux_Mode.set(0) # three traces
22396  Alternate_Sweep_Mode.set(1)
22397  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22398  ADC_Mux_Mode.set(0) # three traces
22399  Alternate_Sweep_Mode.set(1)
22400  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22401  ADC_Mux_Mode.set(0) # three traces
22402  Alternate_Sweep_Mode.set(1)
22403  #
22404  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22405  ADC_Mux_Mode.set(1) # IA and IB
22406  Alternate_Sweep_Mode.set(0)
22407  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
22408  ADC_Mux_Mode.set(1) # just IA
22409  Alternate_Sweep_Mode.set(0)
22410  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22411  ADC_Mux_Mode.set(1) # just IB
22412  Alternate_Sweep_Mode.set(0)
22413  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
22414  ADC_Mux_Mode.set(4) # VA and IA
22415  Alternate_Sweep_Mode.set(0)
22416  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22417  ADC_Mux_Mode.set(5) # VB and IB
22418  Alternate_Sweep_Mode.set(0)
22419  else:
22420  ADC_Mux_Mode.set(0)
22421  Alternate_Sweep_Mode.set(0)
22422  SetADC_Mux()
22423  UpdateTimeTrace()
22424 #
22426  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
22427  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
22428 
22429  RUNstatus.set(0)
22430  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
22431  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
22432  print( filename)
22433  #print DevID
22434  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
22435  try:
22436  print( "Cancel current session.")
22437  session.cancel()
22438  print( session.cancelled)
22439  session.end()
22440  print( "Waiting 5...")
22441  time.sleep(5)
22442  print( "Put board in Samba mode and flash firmware.")
22443  session.flash_firmware(filename)
22444  except:
22445  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
22446 
22454  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
22455  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
22456  Bcloseexit()
22457 
22467  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
22468  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
22469  global FrameRefief, BorderSize
22470 
22471  if OhmStatus.get() == 0:
22472  AWGSync.set(1)
22473  OhmStatus.set(1)
22474  OhmDisp.set(1)
22475  OhmCheckBox()
22476  ohmwindow = Toplevel()
22477  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
22478  ohmwindow.resizable(FALSE,FALSE)
22479  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
22480  frame1 = Frame(ohmwindow, borderwidth=BorderSize, relief=FrameRefief)
22481  frame1.grid(row=0, column=0, sticky=W)
22482  #
22483  buttons = Frame( frame1 )
22484  buttons.grid(row=0, column=0, sticky=W)
22485  omrb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
22486  omrb2.pack(side=LEFT)
22487  omrb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
22488  omrb1.pack(side=LEFT)
22489  #
22490  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
22491  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
22492  OhmA0.config(text = "0.000 Ohms")
22493 
22494  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
22495  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
22496  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
22497  #
22498  TestVA = Frame( frame1 )
22499  TestVA.grid(row=3, column=0, sticky=W)
22500  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
22501  chatestvlab.pack(side=LEFT)
22502  CHATestVEntry = Entry(TestVA, width=6, cursor='double_arrow') #
22503  CHATestVEntry.pack(side=LEFT)
22504  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
22505  CHATestVEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22506  CHATestVEntry.bind("<Button-5>", onTextScroll)
22507  CHATestVEntry.delete(0,"end")
22508  CHATestVEntry.insert(0,5.0)
22509  #
22510  RMode = IntVar(0)
22511  RMode.set(1)
22512  TestMode = Frame( frame1 )
22513  TestMode.grid(row=4, column=0, sticky=W)
22514  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
22515  modelab.pack(side=LEFT)
22516  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
22517  rm3.pack(side=LEFT)
22518  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
22519  rm4.pack(side=LEFT)
22520  #
22521  TestRA = Frame( frame1 )
22522  TestRA.grid(row=5, column=0, sticky=W)
22523  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
22524  chatestrlab.pack(side=LEFT)
22525  CHATestREntry = Entry(TestRA, width=6, cursor='double_arrow') #
22526  CHATestREntry.pack(side=LEFT)
22527  CHATestREntry.bind('<MouseWheel>', onTextScroll)
22528  CHATestREntry.bind("<Button-4>", onTextScroll)# with Linux OS
22529  CHATestREntry.bind("<Button-5>", onTextScroll)
22530  CHATestREntry.delete(0,"end")
22531  CHATestREntry.insert(0,OnBoardRes)
22532  #
22533  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
22534  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
22535 #
22537  global ohmwindow, OhmStatus, OhmDisp
22538 
22539  OhmStatus.set(0)
22540  OhmDisp.set(0)
22541  OhmCheckBox()
22542  ohmwindow.destroy()
22543 #
22545  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
22546  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
22547  global MinigenScreenStatus, DeBugMode
22548  global FrameRefief, BorderSize
22549 
22550  #
22551  if ETSStatus.get() == 0:
22552  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
22553  ETSStatus.set(1)
22554  ETSDisp.set(0)
22555  etswindow = Toplevel()
22556  etswindow.title("ETS Controls " + SWRev + RevDate)
22557  etswindow.resizable(FALSE,FALSE)
22558  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
22559  frame1 = Frame(etswindow, borderwidth=BorderSize, relief=FrameRefief)
22560  frame1.grid(row=0, column=0, sticky=W)
22561  # Sampling controls Widgets
22562  SRstring = "RT Sample Rate = " + str(SAMPLErate)
22563  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
22564  rtsrlab.grid(row=1, column=0, sticky=W)
22565  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
22566  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
22567  etssrlab.grid(row=2, column=0, sticky=W)
22568  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
22569  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
22570  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
22571  enb1.grid(row=4, column=0, sticky=W)
22572  #
22573  Divx = Frame( frame1 )
22574  Divx.grid(row=5, column=0, sticky=W)
22575  DivXEntry = Entry(Divx, width=6, cursor='double_arrow')
22576  DivXEntry.bind('<MouseWheel>', ETSscroll)
22577  DivXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
22578  DivXEntry.bind("<Button-5>", ETSscroll)
22579  DivXEntry.pack(side=RIGHT)
22580  DivXEntry.delete(0,"end")
22581  DivXEntry.insert(0,2)
22582  divxlab = Label( Divx, text = "Divide Factor")
22583  divxlab.pack(side=RIGHT)
22584  GridRow = 5
22585  #
22586  if DeBugMode > 0:
22587  FOffEntry = Label(frame1, text="Samples")
22588  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
22589  MulXEntry = Label( frame1, text = "Rec Len Mul")
22590  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
22591  GridRow = GridRow + 2
22592  #
22593  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
22594  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
22595  #
22596  FConv = Frame( frame1 )
22597  FConv.grid(row=GridRow+2, column=0, sticky=W)
22598  FMulXEntry = Entry(FConv, width=3, cursor='double_arrow')
22599  FMulXEntry.bind('<MouseWheel>', ETSscroll)
22600  FMulXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
22601  FMulXEntry.bind("<Button-5>", ETSscroll)
22602  FMulXEntry.pack(side=RIGHT)
22603  FMulXEntry.delete(0,"end")
22604  FMulXEntry.insert(0,1)
22605  fminlab = Label( FConv, text = "Freq Multiplier")
22606  fminlab.pack(side=RIGHT)
22607  #
22608  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
22609  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
22610  #
22611  if MinigenScreenStatus.get() > 0:
22612  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
22613  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
22614  GridRow = GridRow + 1
22615  #
22616  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
22617  dirlab.grid(row=GridRow+5, column=0, sticky=W)
22618  DataMode = Frame( frame1 )
22619  DataMode.grid(row=GridRow+6, column=0, sticky=W)
22620  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
22621  dm3.pack(side=LEFT)
22622  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
22623  dm4.pack(side=LEFT)
22624  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
22625  tclab.grid(row=GridRow+7, column=0, sticky=W)
22626  TSMode = Frame( frame1 )
22627  TSMode.grid(row=GridRow+8, column=0, sticky=W)
22628  ETSts = Entry(TSMode, width=6, cursor='double_arrow')
22629  ETSts.bind('<MouseWheel>', ETSscroll)
22630  ETSts.bind("<Button-4>", ETSscroll)# with Linux OS
22631  ETSts.bind("<Button-5>", ETSscroll)
22632  ETSts.pack(side=RIGHT)
22633  ETSts.delete(0,"end")
22634  ETSts.insert(0,1)
22635  ETStslab = Label( TSMode, text = "Factor")
22636  ETStslab.pack(side=RIGHT)
22637  #
22638  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
22639  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
22640  ETSDisp.set(0)
22641  ETSCheckBox()
22642 #
22644  global etswindow, ETSStatus, ETSDisp
22645 
22646  ETSStatus.set(0)
22647  ETSDisp.set(0)
22648  ETSCheckBox()
22649  etswindow.destroy()
22650 #
22651 def MGLoad():
22652  global MinigenFout, Fmin, ETSDir
22653 
22654  MinigenFout.delete(0,"end")
22655  if ETSDir.get() == 0:
22656  MinigenFout.insert(0,Fmin+20)
22657  else:
22658  MinigenFout.insert(0,Fmin-20)
22659  BSendMG()
22660 #
22661 def ETSscroll(event):
22662  onTextScroll(event)
22663  ETSUpdate()
22664 #
22665 def onFminScroll(event):
22666  onTextScroll(event)
22667  ETSUpdate()
22668  SetETSComp()
22669  SetAD9833(event)
22670 
22671 def onMulXScroll(event):
22672  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
22673 
22674  onTextScroll(event)
22675  # ETSUpdate()
22676  try:
22677  TscaleX = float(HtMulEntry.get())
22678  except:
22679  HtMulEntry.delete(0,END)
22680  HtMulEntry.insert(0, 1)
22681  if Two_X_Sample.get() == 0:
22682  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
22683  else:
22684  ToffsetX = 0
22685  ETSts.delete(0,"end")
22686  ETSts.insert(0,ToffsetX)
22687  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
22688  etssrlab.config(text=SRstring)
22689  #
22690  SetETSComp()
22691  SetAD9833(event)
22692 #
22694  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
22695  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
22696  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
22697 
22698  if TIMEdiv > 0.2:
22699  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
22700  else:
22701  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
22702  if (MaxETSrecord*100) > MaxSamples:
22703  MaxETSrecord = MaxSamples / 100
22704  try:
22705  DivX = float(eval(DivXEntry.get()))
22706  if DivX < 2:
22707  DivX = 2
22708  if DivX > 75:
22709  DivX = 75
22710  DivXEntry.delete(0,END)
22711  DivXEntry.insert(0, DivX)
22712  except:
22713  DivXEntry.delete(0,END)
22714  DivXEntry.insert(0, DivX)
22715  #
22716  FOff = 25
22717  MulX = (DivX*SAMPLErate)/(100*FOff)
22718  while MulX > MaxETSrecord:
22719  FOff = FOff + 5
22720  MulX = (DivX*SAMPLErate)/(100*FOff)
22721  FOff = 0 - FOff
22722  if DeBugMode > 0:
22723  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
22724  MulXEntry.config(text = SRstring) # change displayed value
22725  SRstring = "Offset = " + str(FOff) + " samples"
22726  FOffEntry.config(text = SRstring) # change displayed value
22727  baseFreq = SAMPLErate/DivX
22728  try:
22729  FMul = float(eval(FMulXEntry.get()))
22730  if FMul < 1:
22731  FMul = 1
22732  FMulXEntry.delete(0,END)
22733  FMulXEntry.insert(0, int(FMul))
22734  if FMul > 75:
22735  FMul = 75
22736  FMulXEntry.delete(0,END)
22737  FMulXEntry.insert(0, int(FMul))
22738  except:
22739  FMulXEntry.delete(0,END)
22740  FMulXEntry.insert(0, int(FMul))
22741  FreqMin = baseFreq * FMul
22742  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
22743  FminDisp.config(text = SRstring) # change displayed value
22744  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
22745  eqivsamplerate.config(text = SRstring) # change displayed value
22746  # calculate time scale multiplication factor
22747  try:
22748  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
22749  except:
22750  FminEntry.delete(0,END)
22751  FminEntry.insert(0, 25)
22752  #
22753  try: # catch for divide by zero
22754  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
22755  except:
22756  TscaleX = 1
22757 
22758  if TscaleX > 0:
22759  ETSDir.set(0) # set sample direction to forward if positive
22760  else:
22761  ETSDir.set(1) # set sample direction to reverse if negative
22762  TscaleX = abs(TscaleX)
22763  if Two_X_Sample.get() == 0:
22764  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
22765  else:
22766  ToffsetX = 0
22767  ETSts.delete(0,"end")
22768  ETSts.insert(0,ToffsetX)
22769 
22770  HtMulEntry.delete(0,END)
22771  HtMulEntry.insert(0, TscaleX)
22772  SRstring = "RT Sample Rate = " + str(SAMPLErate)
22773  rtsrlab.config(text=SRstring)
22774  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
22775  etssrlab.config(text=SRstring)
22776 #
22777 def Settingsscroll(event):
22778  onTextScroll(event)
22779  SettingsUpdate()
22780 #
22781 def SettingsTextKey(event):
22782  onTextKey(event)
22783  SettingsUpdate()
22784 #
22786  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
22787  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
22788  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
22789  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
22790  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
22791  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
22792  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
22793  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
22794  global FrameRefief, BorderSize
22795 
22796  if SettingsStatus.get() == 0:
22797  SettingsStatus.set(1)
22798  Settingswindow = Toplevel()
22799  Settingswindow.title("Settings " + SWRev + RevDate)
22800  Settingswindow.resizable(FALSE,FALSE)
22801  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
22802  frame1 = Frame(Settingswindow, borderwidth=BorderSize, relief=FrameRefief)
22803  frame1.grid(row=0, column=0, sticky=W)
22804  #
22805  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
22806  zstlab.grid(row=0, column=0, sticky=W)
22807  zstMode = Frame( frame1 )
22808  zstMode.grid(row=0, column=1, sticky=W)
22809  ZSTuff = Entry(zstMode, width=4, cursor='double_arrow')
22810  ZSTuff.bind("<Return>", SettingsTextKey)
22811  ZSTuff.bind('<MouseWheel>', Settingsscroll)
22812  ZSTuff.bind("<Button-4>", Settingsscroll)# with Linux OS
22813  ZSTuff.bind("<Button-5>", Settingsscroll)
22814  ZSTuff.bind('<Key>', SettingsTextKey)
22815  ZSTuff.pack(side=RIGHT)
22816  ZSTuff.delete(0,"end")
22817  ZSTuff.insert(0,ZEROstuffing.get())
22818  #
22819  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
22820  Avglab.grid(row=1, column=0, sticky=W)
22821  AvgMode = Frame( frame1 )
22822  AvgMode.grid(row=1, column=1, sticky=W)
22823  TAvg = Entry(AvgMode, width=4, cursor='double_arrow')
22824  TAvg.bind("<Return>", SettingsTextKey)
22825  TAvg.bind('<MouseWheel>', Settingsscroll)
22826  TAvg.bind("<Button-4>", Settingsscroll)# with Linux OS
22827  TAvg.bind("<Button-5>", Settingsscroll)
22828  TAvg.bind('<Key>', SettingsTextKey)
22829  TAvg.pack(side=RIGHT)
22830  TAvg.delete(0,"end")
22831  TAvg.insert(0,TRACEaverage.get())
22832  #
22833  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
22834  HarMlab.grid(row=2, column=0, sticky=W)
22835  HarMMode = Frame( frame1 )
22836  HarMMode.grid(row=2, column=1, sticky=W)
22837  HarMon = Entry(HarMMode, width=4, cursor='double_arrow')
22838  HarMon.bind("<Return>", SettingsTextKey)
22839  HarMon.bind('<MouseWheel>', Settingsscroll)
22840  HarMon.bind("<Button-4>", Settingsscroll)# with Linux OS
22841  HarMon.bind("<Button-5>", Settingsscroll)
22842  HarMon.bind('<Key>', SettingsTextKey)
22843  HarMon.pack(side=RIGHT)
22844  HarMon.delete(0,"end")
22845  HarMon.insert(0,HarmonicMarkers.get())
22846  #
22847  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
22848  Vdivlab.grid(row=3, column=0, sticky=W)
22849  VdivMode = Frame( frame1 )
22850  VdivMode.grid(row=3, column=1, sticky=W)
22851  VDivE = Entry(VdivMode, width=4, cursor='double_arrow')
22852  VDivE.bind("<Return>", SettingsTextKey)
22853  VDivE.bind('<MouseWheel>', Settingsscroll)
22854  VDivE.bind("<Button-4>", Settingsscroll)# with Linux OS
22855  VDivE.bind("<Button-5>", Settingsscroll)
22856  VDivE.bind('<Key>', SettingsTextKey)
22857  VDivE.pack(side=RIGHT)
22858  VDivE.delete(0,"end")
22859  VDivE.insert(0,Vdiv.get())
22860  #
22861  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
22862  Twdthlab.grid(row=4, column=0, sticky=W)
22863  TwdthMode = Frame( frame1 )
22864  TwdthMode.grid(row=4, column=1, sticky=W)
22865  TwdthE = Entry(TwdthMode, width=4, cursor='double_arrow')
22866  TwdthE.bind("<Return>", SettingsTextKey)
22867  TwdthE.bind('<MouseWheel>', Settingsscroll)
22868  TwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
22869  TwdthE.bind("<Button-5>", Settingsscroll)
22870  TwdthE.bind('<Key>', SettingsTextKey)
22871  TwdthE.pack(side=RIGHT)
22872  TwdthE.delete(0,"end")
22873  TwdthE.insert(0,TRACEwidth.get())
22874  #
22875  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
22876  Gwdthlab.grid(row=5, column=0, sticky=W)
22877  GwdthMode = Frame( frame1 )
22878  GwdthMode.grid(row=5, column=1, sticky=W)
22879  GwdthE = Entry(GwdthMode, width=4, cursor='double_arrow')
22880  GwdthE.bind("<Return>", SettingsTextKey)
22881  GwdthE.bind('<MouseWheel>', Settingsscroll)
22882  GwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
22883  GwdthE.bind("<Button-5>", Settingsscroll)
22884  GwdthE.bind('<Key>', SettingsTextKey)
22885  GwdthE.pack(side=RIGHT)
22886  GwdthE.delete(0,"end")
22887  GwdthE.insert(0,GridWidth.get())
22888  #
22889  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
22890  trglpflab.grid(row=6, column=0, sticky=W)
22891  TrgLPFMode = Frame( frame1 )
22892  TrgLPFMode.grid(row=6, column=1, sticky=W)
22893  TrgLPFEntry = Entry(TrgLPFMode, width=4, cursor='double_arrow')
22894  TrgLPFEntry.bind("<Return>", SettingsTextKey)
22895  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
22896  TrgLPFEntry.bind("<Button-4>", Settingsscroll)# with Linux OS
22897  TrgLPFEntry.bind("<Button-5>", Settingsscroll)
22898  TrgLPFEntry.bind('<Key>', SettingsTextKey)
22899  TrgLPFEntry.pack(side=RIGHT)
22900  TrgLPFEntry.delete(0,"end")
22901  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
22902  #
22903  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
22904  AwgAmplrb1.grid(row=7, column=0, sticky=W)
22905  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
22906  AwgAmplrb2.grid(row=7, column=1, sticky=W)
22907  #
22908  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
22909  cha_Rcomplab.grid(row=8, column=0, sticky=W)
22910  cha_RcomplabMode = Frame( frame1 )
22911  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
22912  cha_TC1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
22913  cha_TC1Entry.bind("<Return>", SettingsTextKey)
22914  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
22915  cha_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22916  cha_TC1Entry.bind("<Button-5>", Settingsscroll)
22917  cha_TC1Entry.bind('<Key>', SettingsTextKey)
22918  cha_TC1Entry.pack(side=LEFT)
22919  cha_TC1Entry.delete(0,"end")
22920  cha_TC1Entry.insert(0,CHA_TC1.get())
22921  cha_A1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
22922  cha_A1Entry.bind("<Return>", SettingsTextKey)
22923  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
22924  cha_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22925  cha_A1Entry.bind("<Button-5>", Settingsscroll)
22926  cha_A1Entry.bind('<Key>', SettingsTextKey)
22927  cha_A1Entry.pack(side=LEFT)
22928  cha_A1Entry.delete(0,"end")
22929  cha_A1Entry.insert(0,CHA_A1.get())
22930  #
22931  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
22932  cha_Ccomplab.grid(row=9, column=0, sticky=W)
22933  cha_CcomplabMode = Frame( frame1 )
22934  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
22935  cha_TC2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
22936  cha_TC2Entry.bind("<Return>", SettingsTextKey)
22937  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
22938  cha_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22939  cha_TC2Entry.bind("<Button-5>", Settingsscroll)
22940  cha_TC2Entry.bind('<Key>', SettingsTextKey)
22941  cha_TC2Entry.pack(side=LEFT)
22942  cha_TC2Entry.delete(0,"end")
22943  cha_TC2Entry.insert(0,CHA_TC2.get())
22944  cha_A2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
22945  cha_A2Entry.bind("<Return>", SettingsTextKey)
22946  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
22947  cha_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22948  cha_A2Entry.bind("<Button-5>", Settingsscroll)
22949  cha_A2Entry.bind('<Key>', SettingsTextKey)
22950  cha_A2Entry.pack(side=LEFT)
22951  cha_A2Entry.delete(0,"end")
22952  cha_A2Entry.insert(0,CHA_A2.get())
22953  #
22954  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
22955  chb_Rcomplab.grid(row=10, column=0, sticky=W)
22956  chb_RcomplabMode = Frame( frame1 )
22957  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
22958  chb_TC1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
22959  chb_TC1Entry.bind("<Return>", SettingsTextKey)
22960  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
22961  chb_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22962  chb_TC1Entry.bind("<Button-5>", Settingsscroll)
22963  chb_TC1Entry.bind('<Key>', SettingsTextKey)
22964  chb_TC1Entry.pack(side=LEFT)
22965  chb_TC1Entry.delete(0,"end")
22966  chb_TC1Entry.insert(0,CHB_TC1.get())
22967  chb_A1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
22968  chb_A1Entry.bind("<Return>", SettingsTextKey)
22969  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
22970  chb_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22971  chb_A1Entry.bind("<Button-5>", Settingsscroll)
22972  chb_A1Entry.bind('<Key>', SettingsTextKey)
22973  chb_A1Entry.pack(side=LEFT)
22974  chb_A1Entry.delete(0,"end")
22975  chb_A1Entry.insert(0,CHB_A1.get())
22976  #
22977  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
22978  chb_Ccomplab.grid(row=11, column=0, sticky=W)
22979  chb_CcomplabMode = Frame( frame1 )
22980  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
22981  chb_TC2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
22982  chb_TC2Entry.bind("<Return>", SettingsTextKey)
22983  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
22984  chb_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22985  chb_TC2Entry.bind("<Button-5>", Settingsscroll)
22986  chb_TC2Entry.bind('<Key>', SettingsTextKey)
22987  chb_TC2Entry.pack(side=LEFT)
22988  chb_TC2Entry.delete(0,"end")
22989  chb_TC2Entry.insert(0,CHB_TC2.get())
22990  chb_A2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
22991  chb_A2Entry.bind("<Return>", SettingsTextKey)
22992  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
22993  chb_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22994  chb_A2Entry.bind("<Button-5>", Settingsscroll)
22995  chb_A2Entry.bind('<Key>', SettingsTextKey)
22996  chb_A2Entry.pack(side=LEFT)
22997  chb_A2Entry.delete(0,"end")
22998  chb_A2Entry.insert(0,CHB_A2.get())
22999  #
23000  if EnableHSsampling > 0:
23001  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
23002  hs_ckb1.grid(row=12, column=0, sticky=W)
23003  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
23004  hs1_Complab.grid(row=13, column=0, sticky=W)
23005  hs1_ComplabMode = Frame( frame1 )
23006  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
23007  ets_TC1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
23008  ets_TC1Entry.bind("<Return>", SettingsTextKey)
23009  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
23010  ets_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23011  ets_TC1Entry.bind("<Button-5>", Settingsscroll)
23012  ets_TC1Entry.bind('<Key>', SettingsTextKey)
23013  ets_TC1Entry.pack(side=LEFT)
23014  ets_TC1Entry.delete(0,"end")
23015  ets_TC1Entry.insert(0,ETS_TC1.get())
23016  ets_A1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
23017  ets_A1Entry.bind("<Return>", SettingsTextKey)
23018  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
23019  ets_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23020  ets_A1Entry.bind("<Button-5>", Settingsscroll)
23021  ets_A1Entry.bind('<Key>', SettingsTextKey)
23022  ets_A1Entry.pack(side=LEFT)
23023  ets_A1Entry.delete(0,"end")
23024  ets_A1Entry.insert(0,ETS_A1.get())
23025  #
23026  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
23027  hs2_Complab.grid(row=14, column=0, sticky=W)
23028  hs2_ComplabMode = Frame( frame1 )
23029  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
23030  ets_TC2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
23031  ets_TC2Entry.bind("<Return>", SettingsTextKey)
23032  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
23033  ets_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23034  ets_TC2Entry.bind("<Button-5>", Settingsscroll)
23035  ets_TC2Entry.bind('<Key>', SettingsTextKey)
23036  ets_TC2Entry.pack(side=LEFT)
23037  ets_TC2Entry.delete(0,"end")
23038  ets_TC2Entry.insert(0,ETS_TC2.get())
23039  ets_A2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
23040  ets_A2Entry.bind("<Return>", SettingsTextKey)
23041  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
23042  ets_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23043  ets_A2Entry.bind("<Button-5>", Settingsscroll)
23044  ets_A2Entry.bind('<Key>', SettingsTextKey)
23045  ets_A2Entry.pack(side=LEFT)
23046  ets_A2Entry.delete(0,"end")
23047  ets_A2Entry.insert(0,ETS_A2.get())
23048  #
23049  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
23050  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
23051  else:
23052  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
23053  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
23054 #
23056  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
23057  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
23058  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23059  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
23060  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23061  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23062 
23063  if Auto_ETS_Comp.get() == 1:
23064  try:
23065  MulX = float(HtMulEntry.get())
23066  #
23067  Value = float(ets_TC1Entry.get()) * MulX
23068  cha_TC1Entry.delete(0,"end")
23069  cha_TC1Entry.insert(0, Value)
23070  cha_A1Entry.delete(0,"end")
23071  cha_A1Entry.insert(0, ets_A1Entry.get())
23072  chb_TC1Entry.delete(0,"end")
23073  chb_TC1Entry.insert(0, Value)
23074  chb_A1Entry.delete(0,"end")
23075  chb_A1Entry.insert(0, ets_A1Entry.get())
23076  #
23077  Value = float(ets_TC2Entry.get()) * MulX
23078  cha_TC2Entry.delete(0,"end")
23079  cha_TC2Entry.insert(0, Value)
23080  cha_A2Entry.delete(0,"end")
23081  cha_A2Entry.insert(0, ets_A2Entry.get())
23082  chb_TC2Entry.delete(0,"end")
23083  chb_TC2Entry.insert(0, Value)
23084  chb_A2Entry.delete(0,"end")
23085  chb_A2Entry.insert(0, ets_A2Entry.get())
23086  except:
23087  MulX = 1.0
23088 
23090 
23091  UpdateAWGA()
23092  UpdateAWGB()
23093  ReMakeAWGwaves()
23094 
23096  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
23097  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
23098  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23099  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
23100  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23101  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23102 
23103  try:
23104  GW = int(eval(GwdthE.get()))
23105  if GW < 1:
23106  GW = 1
23107  GwdthE.delete(0,END)
23108  GwdthE.insert(0, int(GW))
23109  if GW > 5:
23110  GW = 5
23111  GwdthE.delete(0,END)
23112  GwdthE.insert(0, int(GW))
23113  except:
23114  GwdthE.delete(0,END)
23115  GwdthE.insert(0, GridWidth.get())
23116  GridWidth.set(GW)
23117  #
23118  try:
23119  T_length = int(eval(TrgLPFEntry.get()))
23120  if T_length < 1:
23121  T_length = 1
23122  TrgLPFEntry.delete(0,END)
23123  TrgLPFEntry.insert(0, int(GW))
23124  if T_length > 100:
23125  T_length = 100
23126  TrgLPFEntry.delete(0,END)
23127  TrgLPFEntry.insert(0, int(GW))
23128  except:
23129  TrgLPFEntry.delete(0,END)
23130  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
23131  Trigger_LPF_length.set(T_length)
23132  #
23133  try:
23134  TW = int(eval(TwdthE.get()))
23135  if TW < 1:
23136  TW = 1
23137  TwdthE.delete(0,END)
23138  TwdthE.insert(0, int(TW))
23139  if TW > 5:
23140  TW = 5
23141  TwdthE.delete(0,END)
23142  TwdthE.insert(0, int(TW))
23143  except:
23144  TwdthE.delete(0,END)
23145  TwdthE.insert(0, TRACEwidth.get())
23146  TRACEwidth.set(TW)
23147  # Number of average sweeps for average mode
23148  try:
23149  TA = int(eval(TAvg.get()))
23150  if TA < 1:
23151  TA = 1
23152  TAvg.delete(0,END)
23153  TAvg.insert(0, int(TA))
23154  if TA > 16:
23155  TA = 16
23156  TAvg.delete(0,END)
23157  TAvg.insert(0, int(TA))
23158  except:
23159  TAvg.delete(0,END)
23160  TAvg.insert(0, TRACEaverage.get())
23161  TRACEaverage.set(TA)
23162  # Number of vertical divisions for spectrum / Bode
23163  try:
23164  VDv = int(eval(VDivE.get()))
23165  if VDv < 1:
23166  VDv = 1
23167  VDivE.delete(0,END)
23168  VDivE.insert(0, int(VDv))
23169  if VDv > 16:
23170  VDv = 16
23171  VDivE.delete(0,END)
23172  VDivE.insert(0, int(VDv))
23173  except:
23174  VDivE.delete(0,END)
23175  VDivE.insert(0, Vdiv.get())
23176  Vdiv.set(VDv)
23177  # number of Harmonic Markers in SA
23178  try:
23179  HM = int(eval(HarMon.get()))
23180  if HM < 1:
23181  HM = 1
23182  HarMon.delete(0,END)
23183  HarMon.insert(0, int(HM))
23184  if HM > 9:
23185  HM =9
23186  HarMon.delete(0,END)
23187  HarMon.insert(0, int(HM))
23188  except:
23189  HarMon.delete(0,END)
23190  HarMon.insert(0, HarmonicMarkers.get())
23191  HarmonicMarkers.set(HM)
23192  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
23193  try:
23194  ZST = int(eval(ZSTuff.get()))
23195  if ZST < 1:
23196  ZST = 1
23197  ZSTuff.delete(0,END)
23198  ZSTuff.insert(0, int(ZST))
23199  if ZST > 5:
23200  ZST = 5
23201  ZSTuff.delete(0,END)
23202  ZSTuff.insert(0, int(ZST))
23203  except:
23204  ZSTuff.delete(0,END)
23205  ZSTuff.insert(0, ZEROstuffing.get())
23206  ZEROstuffing.set(ZST)
23207 #
23208  try:
23209  TC1A = float(cha_TC1Entry.get())
23210  CHA_TC1.set(TC1A)
23211  if TC1A < 0:
23212  TC1A = 0
23213  cha_TC1Entry.delete(0,END)
23214  cha_TC1Entry.insert(0, TC1A)
23215  except:
23216  cha_TC1Entry.delete(0,END)
23217  cha_TC1Entry.insert(0, CHA_TC1.get())
23218  try:
23219  TC2A = float(cha_TC2Entry.get())
23220  CHA_TC2.set(TC2A)
23221  if TC2A < 0:
23222  TC2A = 0
23223  cha_TC2Entry.delete(0,END)
23224  cha_TC2Entry.insert(0, TC2A)
23225  except:
23226  cha_TC2Entry.delete(0,END)
23227  cha_TC2Entry.insert(0, CHA_TC2.get())
23228  #
23229  try:
23230  Gain1A = float(cha_A1Entry.get())
23231  CHA_A1.set(Gain1A)
23232  except:
23233  cha_A1Entry.delete(0,END)
23234  cha_A1Entry.insert(0, CHA_A1.get())
23235  try:
23236  Gain2A = float(cha_A2Entry.get())
23237  CHA_A2.set(Gain2A)
23238  except:
23239  cha_A2Entry.delete(0,END)
23240  cha_A2Entry.insert(0, CHA_A2.get())
23241  #
23242  try:
23243  TC1B = float(chb_TC1Entry.get())
23244  CHB_TC1.set(TC1B)
23245  if TC1B < 0:
23246  TC1B = 0
23247  chb_TC1Entry.delete(0, END)
23248  chb_TC1Entry.insert(0, TC1B)
23249  except:
23250  chb_TC1Entry.delete(0,END)
23251  chb_TC1Entry.insert(0, CHB_TC1.get())
23252  try:
23253  TC2B = float(chb_TC2Entry.get())
23254  CHB_TC2.set(TC2B)
23255  if TC2B < 0:
23256  TC2B = 0
23257  chb_TC2Entry.delete(0, END)
23258  chb_TC2Entry.insert(0, TC2B)
23259  except:
23260  chb_TC2Entry.delete(0,END)
23261  chb_TC2Entry.insert(0, CHB_TC2.get())
23262  #
23263  try:
23264  Gain1B = float(chb_A1Entry.get())
23265  CHB_A1.set(Gain1B)
23266  except:
23267  chb_A1Entry.delete(0,END)
23268  chb_A1Entry.insert(0, CHB_A1.get())
23269  try:
23270  Gain2B = float(chb_A2Entry.get())
23271  CHB_A2.set(Gain2B)
23272  except:
23273  chb_A2Entry.delete(0,END)
23274  chb_A2Entry.insert(0, CHB_A2.get())
23275  # set ETS base comp
23276  #
23277  SetETSComp()
23278 #
23280  global Settingswindow, SettingsStatus
23281 
23282  SettingsStatus.set(0)
23283  SettingsUpdate()
23284  Settingswindow.destroy()
23285 #
23286 def onCanvasMouse_xy(event):
23287  global MouseX, MouseY, MouseWidget
23288 
23289  MouseWidget = event.widget
23290  MouseX, MouseY = event.x, event.y
23291 #
23292 def BSetFmin():
23293  global FminEntry, CHAfreq
23294 
23295  if CHAfreq > 0:
23296  String = '{0:.3f}'.format(CHAfreq/1000)
23297  FminEntry.delete(0,"end")
23298  FminEntry.insert(0,String)
23299 #
23300 def ReSetAGO():
23301  global CHAVGainEntry, CHAVOffsetEntry
23302 
23303  CHAVGainEntry.delete(0,"end")
23304  CHAVGainEntry.insert(0,1.0)
23305  CHAVOffsetEntry.delete(0,"end")
23306  CHAVOffsetEntry.insert(0,0.0)
23307 #
23308 def ReSetBGO():
23309  global CHBVGainEntry, CHBVOffsetEntry
23310 
23311  CHBVGainEntry.delete(0,"end")
23312  CHBVGainEntry.insert(0,1.0)
23313  CHBVOffsetEntry.delete(0,"end")
23314  CHBVOffsetEntry.insert(0,0.0)
23315 #
23317  global CHAIGainEntry, CHAIOffsetEntry
23318 
23319  CHAIGainEntry.delete(0,"end")
23320  CHAIGainEntry.insert(0,1.0)
23321  CHAIOffsetEntry.delete(0,"end")
23322  CHAIOffsetEntry.insert(0,0.0)
23323 #
23325  global CHBIGainEntry, CHBIOffsetEntry
23326 
23327  CHBIGainEntry.delete(0,"end")
23328  CHBIGainEntry.insert(0,1.0)
23329  CHBIOffsetEntry.delete(0,"end")
23330  CHBIOffsetEntry.insert(0,0.0)
23331 #
23333  global EnablePhaseAnalizer, EnableSpectrumAnalizer, EnableBodePlotter, EnableImpedanceAnalizer
23334  global EnableOhmMeter, OOTphckb, OOTBuildPhAScreen, OOTckb3, OOTBuildSpectrumScreen, OOTckb5, ckb1
23335  global OOTBuildBodeScreen, OOTckb4, OOTBuildIAScreen, OOTckb6, OOTBuildOhmScreen, OOTScreenStatus
23336  global OOTwindow, SWRev, RevDate, BorderSize, FrameRefief, OOTdismissclbutton, EnableDigIO
23337  global EnablePIODACMode, EnableMuxMode, EnableMinigenMode, EnablePmodDA1Mode, EnableDigPotMode, EnableGenericSerialMode
23338  global EnableAD5626SerialMode, EnableDigitalFilter, EnableCommandInterface, EnableMeasureScreen, EnableETSScreen
23339 
23340  if OOTScreenStatus.get() == 0:
23341  OOTScreenStatus.set(1)
23342  OOTwindow = Toplevel()
23343  OOTwindow.title("Instruments " + SWRev + RevDate)
23344  OOTwindow.resizable(FALSE,FALSE)
23345  OOTwindow.protocol("WM_DELETE_WINDOW", DestroyOOTwindow)
23346  frame1 = Frame(OOTwindow, borderwidth=BorderSize, relief=FrameRefief)
23347  frame1.grid(row=0, column=0, sticky=W)
23348  #
23349  nextrow = 1
23350  timebtn = Frame( frame1 )
23351  timebtn.grid(row=nextrow, column=0, sticky=W)
23352  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
23353  ckb1.pack(side=LEFT)
23354  timelab = Label(timebtn, text="Time Plot")
23355  timelab.pack(side=LEFT)
23356  nextrow = nextrow + 1
23357  if EnablePhaseAnalizer > 0:
23358  phasebtn = Frame( frame1 )
23359  phasebtn.grid(row=nextrow, column=0, sticky=W)
23360  OOTphckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
23361  OOTphckb.pack(side=LEFT)
23362  OOTBuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
23363  OOTBuildPhAScreen.pack(side=LEFT)
23364  nextrow = nextrow + 1
23365  #
23366  if EnableSpectrumAnalizer > 0:
23367  freqbtn = Frame( frame1 )
23368  freqbtn.grid(row=nextrow, column=0, sticky=W)
23369  OOTckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
23370  OOTckb3.pack(side=LEFT)
23371  OOTBuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
23372  OOTBuildSpectrumScreen.pack(side=LEFT)
23373  nextrow = nextrow + 1
23374  #
23375  if EnableBodePlotter > 0:
23376  bodebtn = Frame( frame1 )
23377  bodebtn.grid(row=nextrow, column=0, sticky=W)
23378  OOTckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
23379  OOTckb5.pack(side=LEFT)
23380  OOTBuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
23381  OOTBuildBodeScreen.pack(side=LEFT)
23382  nextrow = nextrow + 1
23383  #
23384  if EnableImpedanceAnalizer > 0:
23385  impdbtn = Frame( frame1 )
23386  impdbtn.grid(row=nextrow, column=0, sticky=W)
23387  OOTckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
23388  OOTckb4.pack(side=LEFT)
23389  OOTBuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
23390  OOTBuildIAScreen.pack(side=LEFT)
23391  nextrow = nextrow + 1
23392  #
23393  if EnableOhmMeter > 0:
23394  dcohmbtn = Frame( frame1 )
23395  dcohmbtn.grid(row=nextrow, column=0, sticky=W)
23396  OOTckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
23397  OOTckb6.pack(side=LEFT)
23398  OOTBuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
23399  OOTBuildOhmScreen.pack(side=LEFT)
23400  nextrow = nextrow + 1
23401 
23402  if EnableDigIO > 0:
23403  OOTBuildDigScreen = Button(frame1, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
23404  OOTBuildDigScreen.grid(row=nextrow, column=0, sticky=W)
23405  nextrow = nextrow + 1
23406  # Optional plugin tools
23407  if EnablePIODACMode > 0:
23408  OOTBuildDacScreen = Button(frame1, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
23409  OOTBuildDacScreen.grid(row=nextrow, column=0, sticky=W)
23410  nextrow = nextrow + 1
23411  if EnableMuxMode > 0:
23412  OOTBuildMuxScreen = Button(frame1, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
23413  OOTBuildMuxScreen.grid(row=nextrow, column=0, sticky=W)
23414  nextrow = nextrow + 1
23415  if EnableMinigenMode > 0:
23416  OOTBuildMinigenScreen = Button(frame1, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
23417  OOTBuildMinigenScreen.grid(row=nextrow, column=0, sticky=W)
23418  nextrow = nextrow + 1
23419  if EnablePmodDA1Mode > 0:
23420  OOTBuildDA1Screen = Button(frame1, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
23421  OOTBuildDA1Screen.grid(row=nextrow, column=0, sticky=W)
23422  nextrow = nextrow + 1
23423  if EnableDigPotMode >0:
23424  OOTBuildDigPotScreen = Button(frame1, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
23425  OOTBuildDigPotScreen.grid(row=nextrow, column=0, sticky=W)
23426  nextrow = nextrow + 1
23427  if EnableGenericSerialMode >0:
23428  OOTGenericSerialScreen = Button(frame1, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
23429  OOTGenericSerialScreen.grid(row=nextrow, column=0, sticky=W)
23430  nextrow = nextrow + 1
23431  if EnableAD5626SerialMode >0:
23432  OOTAD5626SerialScreen = Button(frame1, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
23433  OOTAD5626SerialScreen.grid(row=nextrow, column=0, sticky=W)
23434  nextrow = nextrow + 1
23435  if EnableDigitalFilter >0:
23436  OOTDigFiltScreen = Button(frame1, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
23437  OOTDigFiltScreen.grid(row=nextrow, column=0, sticky=W)
23438  nextrow = nextrow + 1
23439  if EnableCommandInterface > 0:
23440  OOTCommandLineScreen = Button(frame1, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
23441  OOTCommandLineScreen.grid(row=nextrow, column=0, sticky=W)
23442  nextrow = nextrow + 1
23443  if EnableMeasureScreen > 0:
23444  OOTMeasureScreen = Button(frame1, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
23445  OOTMeasureScreen.grid(row=nextrow, column=0, sticky=W)
23446  nextrow = nextrow + 1
23447  if EnableETSScreen > 0:
23448  OOTETSScreen = Button(frame1, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
23449  OOTETSScreen.grid(row=nextrow, column=0, sticky=W)
23450  nextrow = nextrow + 1
23451  #
23452  OOTdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOOTwindow)
23453  OOTdismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
23454 #
23456  global OOTwindow, OOTScreenStatus
23457 
23458  OOTScreenStatus.set(0)
23459  OOTwindow.destroy()
23460 #
23461 #
23462 # ================ Make main Screen ==========================
23463 TgInput = IntVar(0) # Trigger Input variable
23464 SingleShot = IntVar(0) # variable for single shot triger
23465 ManualTrigger = IntVar(0) # variable for Manual trigger
23466 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
23467 ShowC1_V = IntVar(0) # curves to display variables
23468 TgEdge = IntVar(0) # Trigger edge variable
23469 # Show channels variables
23470 ShowC1_V = IntVar(0) # curves to display variables
23471 ShowC1_I = IntVar(0)
23472 ShowC2_V = IntVar(0)
23473 ShowC2_I = IntVar(0)
23474 ShowAV_I = IntVar(0)
23475 ShowBV_I = IntVar(0)
23476 ShowRA_V = IntVar(0)
23477 ShowRA_I = IntVar(0)
23478 ShowRB_V = IntVar(0)
23479 ShowRB_I = IntVar(0)
23480 ShowMath = IntVar(0)
23481 ShowPB_A = IntVar(0)
23482 ShowPB_B = IntVar(0)
23483 ShowPB_C = IntVar(0)
23484 ShowPB_D = IntVar(0)
23485 # Bode and SA variables
23486 ShowC1_VdB = IntVar(0) # curves to display variables
23487 ShowC1_P = IntVar(0)
23488 ShowC2_VdB = IntVar(0)
23489 ShowC2_P = IntVar(0)
23490 ShowMarker = IntVar(0)
23491 ShowRA_VdB = IntVar(0)
23492 ShowRA_P = IntVar(0)
23493 ShowRB_VdB = IntVar(0)
23494 ShowRB_P = IntVar(0)
23495 ShowMathSA = IntVar(0)
23496 ShowRMath = IntVar(0)
23497 ShowAWGASA = IntVar(0)
23498 ShowAWGBSA = IntVar(0)
23499 HScaleBP = IntVar(0)
23500 HScaleBP.set(1)
23501 #
23502 Show_MathX = IntVar(0)
23503 Show_MathY = IntVar(0)
23504 AutoCenterA = IntVar(0)
23505 AutoCenterB = IntVar(0)
23506 SmoothCurves = IntVar(0)
23507 ZOHold = IntVar(0)
23508 TRACEmodeTime = IntVar(0)
23509 TRACEmodeTime.set(0)
23510 DecimateOption = IntVar(0)
23511 MathTrace = IntVar(0)
23512 # AWG variables
23513 AWGAMode = IntVar(0) # AWG A mode variable
23514 AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
23515 AWGATerm = IntVar(0) # AWG A termination variable
23516 AWGAShape = IntVar(0) # AWG A Wave shape variable
23517 AWGAPhaseDelay = IntVar(0) #
23518 AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
23519 AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
23520 AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
23521 AWGBMode = IntVar(0) # AWG B mode variable
23522 AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
23523 AWGBTerm = IntVar(0) # AWG B termination variable
23524 AWGBShape = IntVar(0) # AWG B Wave shape variable
23525 AWGBPhaseDelay = IntVar(0) #
23526 AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
23527 AWGAMode.set(2)
23528 AWGBMode.set(2)
23529 AWGSync = IntVar(0) # Sync start both AWG channels
23530 AWGSync.set(1)
23531 BisCompA = IntVar(0) # Make Channel B comp of channel A
23532 BisCompA.set(0)
23533 # define vertical measurment variables
23534 MeasDCV1 = IntVar(0)
23535 MeasMinV1 = IntVar(0)
23536 MeasMaxV1 = IntVar(0)
23537 MeasMidV1 = IntVar(0)
23538 MeasPPV1 = IntVar(0)
23539 MeasRMSV1 = IntVar(0)
23540 MeasRMSVA_B = IntVar(0)
23541 MeasDCI1 = IntVar(0)
23542 MeasMinI1 = IntVar(0)
23543 MeasMaxI1 = IntVar(0)
23544 MeasMidI1 = IntVar(0)
23545 MeasPPI1 = IntVar(0)
23546 MeasRMSI1 = IntVar(0)
23547 MeasDiffAB = IntVar(0)
23548 MeasDCV2 = IntVar(0)
23549 MeasMinV2 = IntVar(0)
23550 MeasMaxV2 = IntVar(0)
23551 MeasMidV2 = IntVar(0)
23552 MeasPPV2 = IntVar(0)
23553 MeasRMSV2 = IntVar(0)
23554 MeasDCI2 = IntVar(0)
23555 MeasMinI2 = IntVar(0)
23556 MeasMaxI2 = IntVar(0)
23557 MeasMidI2 = IntVar(0)
23558 MeasPPI2 = IntVar(0)
23559 MeasRMSI2 = IntVar(0)
23560 MeasDiffBA = IntVar(0)
23561 MeasUserA = IntVar(0)
23562 MeasAHW = IntVar(0)
23563 MeasALW = IntVar(0)
23564 MeasADCy = IntVar(0)
23565 MeasAPER = IntVar(0)
23566 MeasAFREQ = IntVar(0)
23567 MeasBHW = IntVar(0)
23568 MeasBLW = IntVar(0)
23569 MeasBDCy = IntVar(0)
23570 MeasBPER = IntVar(0)
23571 MeasBFREQ = IntVar(0)
23572 MeasPhase = IntVar(0)
23573 MeasTopV1 = IntVar(0)
23574 MeasBaseV1 = IntVar(0)
23575 MeasTopV2 = IntVar(0)
23576 MeasBaseV2 = IntVar(0)
23577 MeasUserB = IntVar(0)
23578 MeasDelay = IntVar(0)
23579 TimeDisp = IntVar(0)
23580 TimeDisp.set(1)
23581 XYDisp = IntVar(0)
23582 FreqDisp = IntVar(0)
23583 PhADisp = IntVar(0)
23584 BodeDisp = IntVar(0)
23585 IADisp = IntVar(0)
23586 OhmDisp = IntVar(0)
23587 OOTScreenStatus = IntVar(0)
23588 OOTScreenStatus.set(0)
23589 PhAScreenStatus = IntVar(0)
23590 PhAScreenStatus.set(0)
23591 AppendPhAData = IntVar(0)
23592 AppendPhAData.set(0)
23593 PhAPlotMode = IntVar(0)
23594 PhADatafilename = "PhaseData.csv"
23595 BodeScreenStatus = IntVar(0)
23596 BodeScreenStatus.set(0)
23597 DigScreenStatus = IntVar(0)
23598 DigScreenStatus.set(0)
23599 DacScreenStatus = IntVar(0)
23600 DacScreenStatus.set(0)
23601 MuxScreenStatus = IntVar(0)
23602 MuxScreenStatus.set(0)
23603 MuxEnb = IntVar(0)
23604 MuxSync = IntVar(0)
23605 DualMuxMode = IntVar(0)
23606 ChopMuxMode = IntVar(0)
23607 ChopTrig = IntVar(0)
23608 MinigenScreenStatus = IntVar(0)
23609 MinigenScreenStatus.set(0)
23610 DA1ScreenStatus = IntVar(0)
23611 DA1ScreenStatus.set(0)
23612 DigPotScreenStatus = IntVar(0)
23613 DigPotScreenStatus.set(0)
23614 GenericSerialStatus = IntVar(0)
23615 GenericSerialStatus.set(0)
23616 AD5626SerialStatus = IntVar(0)
23617 AD5626SerialStatus.set(0)
23618 DigFiltStatus = IntVar(0)
23619 DigFiltStatus.set(0)
23620 CommandStatus = IntVar(0)
23621 CommandStatus.set(0)
23622 MeasureStatus = IntVar(0)
23623 MeasureStatus.set(0)
23624 MarkerScale = IntVar(0)
23625 MarkerScale.set(1)
23626 SettingsStatus = IntVar(0)
23627 CHA_RC_HP = IntVar(0)
23628 CHB_RC_HP = IntVar(0)
23629 CHAI_RC_HP = IntVar(0)
23630 CHBI_RC_HP = IntVar(0)
23631 HScale = IntVar(0)
23632 SAVScale = IntVar(0)
23633 SAVPSD = IntVar(0)
23634 SAvertmax = 1.0
23635 SAvertmin = 1.0E-6
23636 #
23637 if GUITheme == "Light": # Can be Light or Dark or Blue or LtBlue
23638  FrameBG = "#d7d7d7"
23639  ButtonText = "#000000"
23640 elif GUITheme == "Dark":
23641  FrameBG = "#484848"
23642  ButtonText = "#ffffff"
23643 elif GUITheme == "Blue":
23644  FrameBG = "#242468"
23645  ButtonText = "#d0d0ff"
23646 elif GUITheme == "LtBlue":
23647  FrameBG = "#c0e8ff"
23648  ButtonText = "#000040"
23649 EntryText = "#000000"
23650 BoxColor = "#0000ff" # 100% blue
23651 root.style.configure("TFrame", background=FrameBG, borderwidth=BorderSize)
23652 root.style.configure("TLabelframe", background=FrameBG)
23653 root.style.configure("TLabel", foreground=ButtonText, background=FrameBG, relief=LabRelief)
23654 root.style.configure("TEntry", foreground=EntryText, background=FrameBG, relief=ButRelief) #cursor='sb_v_double_arrow'
23655 root.style.configure("TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
23656 root.style.configure("TRadiobutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
23657 root.style.configure("TButton", foreground=ButtonText, background=FrameBG, highlightcolor=FrameBG, relief=ButRelief)
23658 # define custom buttons and labels
23659 root.style.configure("TSpinbox", arrowsize=SBoxarrow) # 11 only changes things in Python 3
23660 root.style.configure("W3.TButton", width=3, relief=ButRelief)
23661 root.style.configure("W4.TButton", width=4, relief=ButRelief)
23662 root.style.configure("W5.TButton", width=5, relief=ButRelief)
23663 root.style.configure("W6.TButton", width=6, relief=ButRelief)
23664 root.style.configure("W7.TButton", width=7, relief=ButRelief)
23665 root.style.configure("W8.TButton", width=8, relief=ButRelief)
23666 root.style.configure("W9.TButton", width=9, relief=ButRelief)
23667 root.style.configure("W10.TButton", width=10, relief=ButRelief)
23668 root.style.configure("W11.TButton", width=11, relief=ButRelief)
23669 root.style.configure("W16.TButton", width=16, relief=ButRelief)
23670 root.style.configure("W17.TButton", width=17, relief=ButRelief)
23671 root.style.configure("Stop.TButton", background=ButtonRed, foreground="#000000", width=4, relief=ButRelief)
23672 root.style.configure("Run.TButton", background=ButtonGreen, foreground="#000000", width=4, relief=ButRelief)
23673 root.style.configure("Pwr.TButton", background=ButtonGreen, foreground="#000000", width=8, relief=ButRelief)
23674 root.style.configure("PwrOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
23675 root.style.configure("Roll.TButton", background=ButtonGreen, foreground="#000000", width=7, relief=ButRelief)
23676 root.style.configure("RollOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
23677 root.style.configure("RConn.TButton", background=ButtonRed, foreground="#000000", width=5, relief=ButRelief)
23678 root.style.configure("GConn.TButton", background=ButtonGreen, foreground="#000000", width=5, relief=ButRelief)
23679 root.style.configure("Rtrace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=RAISED)
23680 root.style.configure("Strace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=SUNKEN)
23681 root.style.configure("Ctrace1.TButton", background=COLORtrace1, foreground="#000000", relief=ButRelief)
23682 root.style.configure("Rtrace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=RAISED)
23683 root.style.configure("Strace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=SUNKEN)
23684 root.style.configure("Ctrace2.TButton", background=COLORtrace2, foreground="#000000", relief=ButRelief)
23685 root.style.configure("Rtrace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=RAISED)
23686 root.style.configure("Strace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=SUNKEN)
23687 root.style.configure("Ctrace3.TButton", background=COLORtrace3, foreground="#000000", relief=ButRelief)
23688 root.style.configure("Rtrace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=RAISED)
23689 root.style.configure("Strace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=SUNKEN)
23690 root.style.configure("Ctrace4.TButton", background=COLORtrace4, foreground="#000000", relief=ButRelief)
23691 root.style.configure("Rtrace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=RAISED)
23692 root.style.configure("Strace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=SUNKEN)
23693 root.style.configure("Rtrace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=RAISED)
23694 root.style.configure("Strace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=SUNKEN)
23695 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
23696 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
23697 #
23698 root.style.configure("A10T5.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR5, font=('Arial', 10, 'bold'))
23699 root.style.configure("A10T5.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23700 root.style.configure("A10T6.TLabelframe.Label", background=FrameBG, foreground=COLORtrace6, font=('Arial', 10, 'bold'))
23701 root.style.configure("A10T6.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23702 root.style.configure("A10T7.TLabelframe.Label", background=FrameBG, foreground=COLORtrace7, font=('Arial', 10, 'bold'))
23703 root.style.configure("A10T7.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23704 #
23705 root.style.configure("A10R1.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
23706 root.style.configure("A10R1.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23707 root.style.configure("A10R2.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
23708 root.style.configure("A10R2.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23709 root.style.configure("A10.TLabelframe.Label", background=FrameBG, font=('Arial', 10, 'bold'))
23710 root.style.configure("A10.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23711 root.style.configure("A10B.TLabel", foreground=ButtonText, font="Arial 10 bold") # Black text
23712 root.style.configure("A10R.TLabel", foreground=ButtonRed, font="Arial 10 bold") # Red text
23713 root.style.configure("A10G.TLabel", foreground=ButtonGreen, font="Arial 10 bold") # Red text
23714 root.style.configure("A12B.TLabel", foreground=ButtonText, font="Arial 12 bold") # Black text
23715 root.style.configure("A16B.TLabel", foreground=ButtonText, font="Arial 16 bold") # Black text
23716 root.style.configure("Stop.TRadiobutton", background=ButtonRed, indicatorcolor=FrameBG)
23717 root.style.configure("Run.TRadiobutton", background=ButtonGreen, indicatorcolor=FrameBG)
23718 root.style.configure("Disab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonRed)
23719 root.style.configure("Enab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonGreen)
23720 root.style.configure("Strace1.TCheckbutton", background=COLORtrace1, foreground="#000000", indicatorcolor="#ffffff")
23721 root.style.configure("Strace2.TCheckbutton", background=COLORtrace2, foreground="#000000", indicatorcolor="#ffffff")
23722 root.style.configure("Strace3.TCheckbutton", background=COLORtrace3, foreground="#000000", indicatorcolor="#ffffff")
23723 root.style.configure("Strace4.TCheckbutton", background=COLORtrace4, foreground="#000000", indicatorcolor="#ffffff")
23724 root.style.configure("Strace6.TCheckbutton", background=COLORtrace6, foreground="#000000", indicatorcolor="#ffffff")
23725 root.style.configure("Strace7.TCheckbutton", background=COLORtrace7, foreground="#000000", indicatorcolor="#ffffff")
23726 root.style.configure("WPhase.TRadiobutton", width=5, foreground="#000000", background="white", indicatorcolor=("red", "green"))
23727 root.style.configure("GPhase.TRadiobutton", width=5, foreground="#000000", background="gray", indicatorcolor=("red", "green"))
23728 # Create frames
23729 frame2r = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23730 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
23731 
23732 frame1 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23733 frame1.pack(side=TOP, fill=BOTH, expand=NO)
23734 
23735 frame2 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23736 frame2.pack(side=TOP, fill=BOTH, expand=YES)
23737 
23738 frame3 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23739 frame3.pack(side=TOP, fill=BOTH, expand=NO)
23740 # create a pulldown menu
23741 # Trigger signals
23742 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
23743 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
23744 Triggermenu["menu"] = Triggermenu.menu
23745 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
23746 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
23747 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
23748 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
23749 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
23750 Triggermenu.menu.add_radiobutton(label='CA-V or CB-V', variable=TgInput, value=5)
23751 # Triggermenu.menu.add_radiobutton(label='Alternate A/B', variable=TgInput, value=6)
23752 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
23753 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
23754 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
23755 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
23756 Triggermenu.pack(side=LEFT)
23757 #
23758 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
23759 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
23760 Edgemenu["menu"] = Edgemenu.menu
23761 Edgemenu.menu.add_radiobutton(label='Rising (+)', variable=TgEdge, value=0)
23762 Edgemenu.menu.add_radiobutton(label='Falling (-)', variable=TgEdge, value=1)
23763 Edgemenu.pack(side=LEFT)
23764 #
23765 tlab = Label(frame1, text="Trig Level")
23766 tlab.pack(side=LEFT)
23767 TRIGGERentry = Entry(frame1, width=5, cursor='double_arrow')
23768 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
23769 TRIGGERentry.bind("<Button-4>", onTextScroll)# with Linux OS
23770 TRIGGERentry.bind("<Button-5>", onTextScroll)
23771 TRIGGERentry.bind("<Return>", BTriglevel)
23772 TRIGGERentry.bind('<Key>', onTextKey)
23773 TRIGGERentry.pack(side=LEFT)
23774 TRIGGERentry.delete(0,"end")
23775 TRIGGERentry.insert(0,0.0)
23776 #
23777 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
23778 tgb.pack(side=LEFT)
23779 #
23780 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
23781 hldlab.pack(side=LEFT)
23782 HoldOffentry = Entry(frame1, width=4, cursor='double_arrow')
23783 HoldOffentry.bind('<MouseWheel>', onTextScroll)
23784 HoldOffentry.bind("<Button-4>", onTextScroll)# with Linux OS
23785 HoldOffentry.bind("<Button-5>", onTextScroll)
23786 HoldOffentry.bind("<Return>", BHoldOff)
23787 HoldOffentry.bind('<Key>', onTextKey)
23788 HoldOffentry.pack(side=LEFT)
23789 HoldOffentry.delete(0,"end")
23790 HoldOffentry.insert(0,0.0)
23791 #
23792 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
23793 hozlab.pack(side=LEFT)
23794 HozPossentry = Entry(frame1, width=4, cursor='double_arrow')
23795 HozPossentry.bind('<MouseWheel>', onTextScroll)
23796 HozPossentry.bind("<Button-4>", onTextScroll)# with Linux OS
23797 HozPossentry.bind("<Button-5>", onTextScroll)
23798 HozPossentry.bind("<Return>", BHozPoss)
23799 HozPossentry.bind('<Key>', onTextKey)
23800 HozPossentry.pack(side=LEFT)
23801 HozPossentry.delete(0,"end")
23802 HozPossentry.insert(0,0.0)
23803 #
23804 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
23805 bexit.pack(side=RIGHT)
23806 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
23807 bstop.pack(side=RIGHT)
23808 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
23809 brun.pack(side=RIGHT)
23810 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
23811 PwrBt.pack(side=RIGHT)
23812 # Curves Menu
23813 if EnableScopeOnly == 0:
23814  Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
23815 else:
23816  Showmenu = Menubutton(frame1, text="Traces", style="W7.TButton")
23817 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
23818 Showmenu["menu"] = Showmenu.menu
23819 Showmenu.menu.add_command(label="-Show Traces-", foreground="blue", command=donothing)
23820 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
23821 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
23822 Showmenu.menu.add_checkbutton(label='CA-V (1)', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
23823 Showmenu.menu.add_checkbutton(label='CA-I (3)', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
23824 Showmenu.menu.add_checkbutton(label='CB-V (2)', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
23825 Showmenu.menu.add_checkbutton(label='CB-I (4)', background=COLORtrace4,variable=ShowC2_I, command=TraceSelectADC_Mux)
23826 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
23827 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
23828 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
23829 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
23830 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
23831 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
23832 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
23833 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
23834 if EnableHSsampling > 0:
23835  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
23836  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
23837 Showmenu.menu.add_separator()
23838 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
23839 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
23840 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
23841 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
23842 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
23843 Showmenu.menu.add_separator()
23844 Showmenu.menu.add_checkbutton(label='T Cursor (t)', variable=ShowTCur, command=UpdateTimeTrace)
23845 Showmenu.menu.add_checkbutton(label='V Cursor (v)', variable=ShowVCur, command=UpdateTimeTrace)
23846 Showmenu.pack(side=RIGHT)
23847 #
23848 if ShowBallonHelp > 0:
23849  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
23850  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
23851  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
23852  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
23853  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
23854  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
23855  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
23856  brun_tip = CreateToolTip(brun, 'Start acquiring data')
23857  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
23858  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
23859 
23860 # Sampling controls Widgets
23861 if EnableHSsampling > 0:
23862  fminlab2 = Label(frame1, text="KHz")
23863  fminlab2.pack(side=RIGHT)
23864  FminEntry = Entry(frame1, width=6, cursor='double_arrow')
23865  FminEntry.bind('<MouseWheel>', onFminScroll)
23866  FminEntry.bind("<Button-4>", onFminScroll)# with Linux OS
23867  FminEntry.bind("<Button-5>", onFminScroll)
23868  FminEntry.bind("<Return>", SetAD9833)
23869  FminEntry.pack(side=RIGHT)
23870  FminEntry.delete(0,"end")
23871  FminEntry.insert(0,25)
23872  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
23873  fminlab.pack(side=RIGHT)
23874  #
23875  HtMulEntry = Entry(frame1, width=4, cursor='double_arrow')
23876  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
23877  HtMulEntry.bind("<Button-4>", onMulXScroll)# with Linux OS
23878  HtMulEntry.bind("<Button-5>", onMulXScroll)
23879  HtMulEntry.bind("<Return>", SetAD9833)
23880  HtMulEntry.pack(side=RIGHT)
23881  HtMulEntry.delete(0,"end")
23882  HtMulEntry.insert(0,1)
23883  mulxlab = Label( frame1, text = "Mul X")
23884  mulxlab.pack(side=RIGHT)
23885 else:
23886  RollBt = Button(frame1, text="Roll-Off", style="RollOff.TButton", command=BRoll)
23887  RollBt.pack(side=RIGHT)
23888 #
23889 # Time per Div
23890 TMsb = Spinbox(frame1, width=5, values= TMpdiv, cursor='double_arrow', command=BTime)
23891 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
23892 TMsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
23893 TMsb.bind("<Button-5>", onSpinBoxScroll)
23894 TMsb.pack(side=RIGHT)
23895 TMsb.delete(0,"end")
23896 TMsb.insert(0,0.5)
23897 TMlab = Label(frame1, text="Time mS/Div")
23898 TMlab.pack(side=RIGHT)
23899 #
23900 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
23901 # add mouse left and right button click to canvas
23902 ca.bind('<Configure>', CAresize)
23903 ca.bind('<1>', onCanvasClickLeft)
23904 ca.bind('<3>', onCanvasClickRight)
23905 ca.bind("<Motion>",onCanvasMouse_xy)
23906 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
23907 ca.bind("<Down>", onCanvasDownArrow)
23908 ca.bind("<Left>", onCanvasLeftArrow)
23909 ca.bind("<Right>", onCanvasRightArrow)
23910 ca.bind("<space>", onCanvasSpaceBar)
23911 ca.bind("1", onCanvasOne)
23912 ca.bind("2", onCanvasTwo)
23913 ca.bind("3", onCanvasThree)
23914 ca.bind("4", onCanvasFour)
23915 ca.bind("5", onCanvasFive)
23916 ca.bind("6", onCanvasSix)
23917 ca.bind("7", onCanvasSeven)
23918 ca.bind("8", onCanvasEight)
23919 ca.bind("9", onCanvasNine)
23920 ca.bind("0", onCanvasZero)
23921 ca.bind("a", onCanvasAverage)
23922 ca.bind("t", onCanvasShowTcur)
23923 ca.bind("v", onCanvasShowVcur)
23924 ca.bind("s", onCanvasSnap)
23925 ca.bind("+", onCanvasTrising)
23926 ca.bind("-", onCanvasTfalling)
23927 ca.bind('<MouseWheel>', onCanvasClickScroll)
23928 ca.bind("<Button-4>", onCanvasClickScroll)# with Linux OS
23929 ca.bind("<Button-5>", onCanvasClickScroll)
23930 ca.pack(side=TOP, fill=BOTH, expand=YES)
23931 MouseWidget = ca
23932 # right side menu buttons
23933 dropmenu = Frame( frame2r )
23934 dropmenu.pack(side=TOP)
23935 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
23936 bcon.pack(side=LEFT, anchor=W)
23937 # File menu
23938 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
23939 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
23940 Filemenu["menu"] = Filemenu.menu
23941 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
23942 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
23943 Filemenu.menu.add_command(label="Run Script", command=RunScript)
23944 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
23945 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
23946 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
23947 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
23948 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
23949 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
23950 Filemenu.menu.add_command(label="Help", command=BHelp)
23951 Filemenu.menu.add_command(label="About", command=BAbout)
23952 Filemenu.pack(side=LEFT, anchor=W)
23953 # Options Menu
23954 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
23955 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
23956 Optionmenu["menu"] = Optionmenu.menu
23957 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
23958 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
23959 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
23960 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
23961 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
23962 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
23963 Optionmenu.menu.add_checkbutton(label='Trace Avg (a)', variable=TRACEmodeTime)
23964 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
23965 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
23966 Optionmenu.menu.add_command(label='Change Plot Label', command=BUserCustomPlotText)
23967 Optionmenu.menu.add_command(label="SnapShot (s)", command=BSnapShot)
23968 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
23969 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
23970 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
23971 if EnableScopeOnly != 0:
23972  Optionmenu.menu.add_command(label="Open Instruments", command=OpenOtherTools)
23973 if AllowFlashFirmware == 1:
23974  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
23975  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
23976 Optionmenu.pack(side=LEFT, anchor=W)
23977 #
23978 dropmenu2 = Frame( frame2r )
23979 dropmenu2.pack(side=TOP)
23980 # Open Math trace menu
23981 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
23982 mathbt.pack(side=RIGHT, anchor=W)
23983 # Measurments menu
23984 measlab = Label(dropmenu2, text="Meas")
23985 measlab.pack(side=LEFT, anchor=W)
23986 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
23987 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
23988 MeasmenuA["menu"] = MeasmenuA.menu
23989 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
23990 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
23991 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
23992 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
23993 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
23994 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
23995 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
23996 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
23997 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
23998 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
23999 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
24000 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
24001 #MeasmenuA.menu.add_separator()
24002 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
24003 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
24004 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
24005 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
24006 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
24007 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
24008 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
24009 #MeasmenuA.menu.add_separator()
24010 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
24011 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
24012 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
24013 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
24014 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
24015 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
24016 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
24017 #
24018 MeasmenuA.pack(side=LEFT)
24019 #
24020 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
24021 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
24022 MeasmenuB["menu"] = MeasmenuB.menu
24023 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
24024 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
24025 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
24026 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
24027 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
24028 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
24029 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
24030 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
24031 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
24032 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
24033 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
24034 #MeasmenuB.menu.add_separator()
24035 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
24036 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
24037 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
24038 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
24039 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
24040 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
24041 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
24042 #MeasmenuB.menu.add_separator()
24043 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
24044 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
24045 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
24046 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
24047 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
24048 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
24049 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
24050 MeasmenuB.pack(side=LEFT)
24051 if ShowBallonHelp > 0:
24052  math_tip = CreateToolTip(mathbt, 'Open Math window')
24053  options_tip = CreateToolTip(Optionmenu, 'Select Optional Settings')
24054  file_tip = CreateToolTip(Filemenu, 'Select File operations')
24055 #
24056 DigScreenStatus = IntVar(0)
24057 DigScreenStatus.set(0)
24058 #
24059 if EnableScopeOnly == 0:
24060  BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
24061  BuildAWGScreen.pack(side=TOP)
24062  # Mode selector
24063  timebtn = Frame( frame2r )
24064  timebtn.pack(side=TOP)
24065  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
24066  ckb1.pack(side=LEFT)
24067  timelab = Label(timebtn, text="Time Plot")
24068  timelab.pack(side=LEFT)
24069  if EnableXYPlotter > 0:
24070  xybtn = Frame( frame2r )
24071  xybtn.pack(side=TOP)
24072  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24073  ckb2.pack(side=LEFT)
24074  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24075  BuildXYScreen.pack(side=TOP)
24076  #
24077  if EnablePhaseAnalizer > 0:
24078  phasebtn = Frame( frame2r )
24079  phasebtn.pack(side=TOP)
24080  phckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
24081  phckb.pack(side=LEFT)
24082  BuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
24083  BuildPhAScreen.pack(side=LEFT)
24084  #
24085  if EnableSpectrumAnalizer > 0:
24086  freqbtn = Frame( frame2r )
24087  freqbtn.pack(side=TOP)
24088  ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
24089  ckb3.pack(side=LEFT)
24090  BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
24091  BuildSpectrumScreen.pack(side=LEFT)
24092  #
24093  if EnableBodePlotter > 0:
24094  bodebtn = Frame( frame2r )
24095  bodebtn.pack(side=TOP)
24096  ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
24097  ckb5.pack(side=LEFT)
24098  BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
24099  BuildBodeScreen.pack(side=LEFT)
24100  #
24101  if EnableImpedanceAnalizer > 0:
24102  impdbtn = Frame( frame2r )
24103  impdbtn.pack(side=TOP)
24104  ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
24105  ckb4.pack(side=LEFT)
24106  BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
24107  BuildIAScreen.pack(side=LEFT)
24108  #
24109  if EnableOhmMeter > 0:
24110  dcohmbtn = Frame( frame2r )
24111  dcohmbtn.pack(side=TOP)
24112  ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
24113  ckb6.pack(side=LEFT)
24114  BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
24115  BuildOhmScreen.pack(side=LEFT)
24116  #
24117  if ShowTraceControls > 0:
24118  Labelfonttext = "Arial " + str(FontSize) + " bold"
24119  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24120  tracelab.pack(side=TOP)
24121  trctrla = Frame( frame2r )
24122  trctrla.pack(side=TOP)
24123  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24124  ckbt1.pack(side=LEFT,fill=X)
24125  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24126  ckbt2.pack(side=LEFT,fill=X)
24127  trctrlb = Frame( frame2r )
24128  trctrlb.pack(side=TOP)
24129  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24130  ckbt3.pack(side=LEFT,fill=X)
24131  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24132  ckbt4.pack(side=LEFT,fill=X)
24133 
24134  if ShowBallonHelp > 0:
24135  try:
24136  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
24137  except:
24138  donothing()
24139  try:
24140  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
24141  except:
24142  donothing()
24143  try:
24144  BuildPhAScreen_tip = CreateToolTip(BuildPhAScreen, 'Open Phase Analyzer window')
24145  except:
24146  donothing()
24147  try:
24148  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open Spectrum Analyzer window')
24149  except:
24150  donothing()
24151  try:
24152  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
24153  except:
24154  donothing()
24155  try:
24156  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance Analyzer window')
24157  except:
24158  donothing()
24159  try:
24160  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
24161  except:
24162  donothing()
24163  # Digital Input / Output Option screens
24164  if EnableDigIO > 0:
24165  BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
24166  BuildDigScreen.pack(side=TOP)
24167  # Optional plugin tools
24168  if EnablePIODACMode > 0:
24169  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
24170  BuildDacScreen.pack(side=TOP)
24171  if EnableMuxMode > 0:
24172  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
24173  BuildMuxScreen.pack(side=TOP)
24174  if EnableMinigenMode > 0:
24175  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
24176  BuildMinigenScreen.pack(side=TOP)
24177  if EnablePmodDA1Mode > 0:
24178  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
24179  BuildDA1Screen.pack(side=TOP)
24180  if EnableDigPotMode >0:
24181  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
24182  BuildDigPotScreen.pack(side=TOP)
24183  if EnableGenericSerialMode >0:
24184  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
24185  GenericSerialScreen.pack(side=TOP)
24186  if EnableAD5626SerialMode >0:
24187  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
24188  AD5626SerialScreen.pack(side=TOP)
24189  if EnableDigitalFilter >0:
24190  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
24191  DigFiltScreen.pack(side=TOP)
24192  if EnableCommandInterface > 0:
24193  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
24194  CommandLineScreen.pack(side=TOP)
24195  if EnableMeasureScreen > 0:
24196  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
24197  MeasureScreen.pack(side=TOP)
24198  if EnableETSScreen > 0:
24199  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
24200  ETSScreen.pack(side=TOP)
24201 else:
24202 # Mode selector
24203  if EnableXYPlotter > 0:
24204  xybtn = Frame( frame2r )
24205  xybtn.pack(side=TOP)
24206  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24207  ckb2.pack(side=LEFT)
24208  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24209  BuildXYScreen.pack(side=TOP)
24210  #
24211  if ShowTraceControls > 0:
24212  Labelfonttext = "Arial " + str(FontSize) + " bold"
24213  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24214  tracelab.pack(side=TOP)
24215  trctrla = Frame( frame2r )
24216  trctrla.pack(side=TOP)
24217  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24218  ckbt1.pack(side=LEFT,fill=X)
24219  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24220  ckbt2.pack(side=LEFT,fill=X)
24221  trctrlb = Frame( frame2r )
24222  trctrlb.pack(side=TOP)
24223  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24224  ckbt3.pack(side=LEFT,fill=X)
24225  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24226  ckbt4.pack(side=LEFT,fill=X)
24227  #
24228  awg1eb = Frame( frame2r )
24229  awg1eb.pack(side=TOP)
24230  ModeAMenu = Menubutton(awg1eb, text="Mode", width=5, style="Ctrace1.TButton")#, style="W5.TButton")
24231  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
24232  ModeAMenu["menu"] = ModeAMenu.menu
24233  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
24234  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
24235  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
24236  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
24237  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
24238  ModeAMenu.menu.add_separator()
24239  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
24240  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
24241  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
24242  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
24243  ModeAMenu.pack(side=LEFT, anchor=W)
24244  ShapeAMenu = Menubutton(awg1eb, text="Shape", width=6, style="Ctrace1.TButton")#, style="W6.TButton")
24245  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
24246  ShapeAMenu["menu"] = ShapeAMenu.menu
24247  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
24248  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
24249  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
24250  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
24251  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
24252  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
24253  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
24254  if AWGShowAdvanced.get() > 0:
24255  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
24256  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
24257  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
24258  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
24259  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
24260  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
24261  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
24262  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
24263  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
24264  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
24265  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
24266  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
24267  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
24268  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
24269  else:
24270  ShapeAMenu.menu.add_separator()
24271  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
24272  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
24273  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
24274  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
24275  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
24276  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
24277  ShapeAMenu.pack(side=LEFT, anchor=W)
24278  #
24279  awg1model = Frame( frame2r )
24280  awg1model.pack(side=TOP,fill=X) #)
24281  AWGAModeLabel = Label(awg1model, text="AWG A Mode", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
24282  AWGAModeLabel.pack(side=LEFT, fill=X)
24283  AWGAShapeLabel = Label(awg1model, text="AWG A Shape", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
24284  AWGAShapeLabel.pack(side=LEFT, fill=X)
24285  #
24286  awg1ampl = Frame( frame2r )
24287  awg1ampl.pack(side=TOP,fill=X) #)
24288  amp1lab = Label(awg1ampl) #
24289  amp1lab.grid(row=0,column=0,sticky=E+S+N+W)
24290  off1lab = Label(awg1ampl) #
24291  off1lab.grid(row=0,column=1,sticky=E+S+N+W)
24292  freq1lab = Label(awg1ampl, text="Freq")
24293  freq1lab.grid(row=0,column=2,sticky=E+S+N+W)
24294  #
24295  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
24296  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
24297  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
24298  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24299  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
24300  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
24301  AWGAAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
24302  AWGAAmplEntry.delete(0,"end")
24303  AWGAAmplEntry.insert(0,0.0)
24304  #
24305  AWGAOffsetEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
24306  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
24307  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
24308  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24309  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
24310  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
24311  AWGAOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
24312  AWGAOffsetEntry.delete(0,"end")
24313  AWGAOffsetEntry.insert(0,0.0)
24314 
24315  if AWG_Amp_Mode.get() == 0:
24316  amp1lab.config(text = "Min" ) # change displayed value
24317  off1lab.config(text = "Max" ) # change displayed value
24318  else:
24319  amp1lab.config(text = "Amp" )
24320  off1lab.config(text = "Off" )
24321  # AWG Frequency sub frame
24322  AWGAFreqEntry = Entry(awg1ampl, width=7, cursor='double_arrow')
24323  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
24324  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
24325  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24326  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
24327  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
24328  AWGAFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
24329  AWGAFreqEntry.delete(0,"end")
24330  AWGAFreqEntry.insert(0,100.0)
24331  # AWG Phase or delay select sub frame
24332  # AWG Phase entry sub frame
24333  awg1phase = Frame( frame2r )
24334  awg1phase.pack(side=TOP)
24335  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
24336  awgaph.pack(side=LEFT, anchor=W)
24337  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
24338  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
24339  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
24340  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24341  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
24342  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
24343  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
24344  AWGAPhaseEntry.delete(0,"end")
24345  AWGAPhaseEntry.insert(0,0)
24346  phasealab = Label(awg1phase, text="Deg")
24347  phasealab.pack(side=LEFT, anchor=W)
24348  # AWG duty cycle frame
24349  awg1dc = Frame( frame2r )
24350  awg1dc.pack(side=TOP)
24351  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
24352  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
24353  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
24354  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24355  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
24356  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
24357  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
24358  AWGADutyCycleEntry.delete(0,"end")
24359  AWGADutyCycleEntry.insert(0,50)
24360  duty1lab = Label(awg1dc, text="%")
24361  duty1lab.pack(side=LEFT, anchor=W)
24362 
24375  awg2eb = Frame( frame2r )
24376  awg2eb.pack(side=TOP)
24377  ModeBMenu = Menubutton(awg2eb, text="Mode", width=5, style="Ctrace2.TButton")# , style="W5.TButton")
24378  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
24379  ModeBMenu["menu"] = ModeBMenu.menu
24380  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
24381  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
24382  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
24383  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
24384  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
24385  ModeBMenu.menu.add_separator()
24386  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
24387  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
24388  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
24389  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
24390  ModeBMenu.pack(side=LEFT, anchor=W)
24391  ShapeBMenu = Menubutton(awg2eb, text="Shape", width=6, style="Ctrace2.TButton")#, style="W6.TButton")
24392  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
24393  ShapeBMenu["menu"] = ShapeBMenu.menu
24394  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
24395  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
24396  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
24397  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
24398  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
24399  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
24400  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
24401  if AWGShowAdvanced.get() > 0:
24402  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
24403  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
24404  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
24405  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
24406  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
24407  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
24408  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
24409  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
24410  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
24411  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
24412  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
24413  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
24414  else:
24415  ShapeBMenu.menu.add_separator()
24416  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
24417  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
24418  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
24419  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
24420  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
24421  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
24422  ShapeBMenu.pack(side=LEFT, anchor=W)
24423  #
24424  awg2model = Frame( frame2r )
24425  awg2model.pack(side=TOP,fill=X) #)
24426  AWGBModeLabel = Label(awg2model, text="AWG B Mode", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
24427  AWGBModeLabel.pack(side=LEFT, fill=X)
24428  AWGBShapeLabel = Label(awg2model, text="AWG B Shape", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
24429  AWGBShapeLabel.pack(side=LEFT, fill=X)
24430  #
24431  awg2ampl = Frame( frame2r )
24432  awg2ampl.pack(side=TOP)
24433  amp2lab = Label(awg2ampl) #, text="Min Ch B")
24434  amp2lab.grid(row=0,column=0,sticky=E+S+N+W)
24435  #amp2lab.pack(side=LEFT, anchor=W)
24436  off2lab = Label(awg2ampl) #, text="Max Ch B")
24437  off2lab.grid(row=0,column=1,sticky=E+S+N+W)
24438  #off2lab.pack(side=LEFT, anchor=W)
24439  freq2lab = Label(awg2ampl, text="Freq")
24440  freq2lab.grid(row=0,column=2,sticky=E+S+N+W)
24441  # freq2lab.pack(side=LEFT, anchor=W)
24442  #
24443  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
24444  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
24445  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
24446  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24447  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
24448  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
24449  AWGBAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
24450  AWGBAmplEntry.delete(0,"end")
24451  AWGBAmplEntry.insert(0,0.0)
24452  #
24453  AWGBOffsetEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
24454  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
24455  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
24456  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24457  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
24458  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
24459  AWGBOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
24460  AWGBOffsetEntry.delete(0,"end")
24461  AWGBOffsetEntry.insert(0,0.0)
24462 
24463  if AWG_Amp_Mode.get() == 0:
24464  amp2lab.config(text = "Min" ) # change displayed value
24465  off2lab.config(text = "Max" ) # change displayed value
24466  else:
24467  amp2lab.config(text = "Amp" )
24468  off2lab.config(text = "Off" )
24469  # AWG Frequency
24470  AWGBFreqEntry = Entry(awg2ampl, width=7, cursor='double_arrow')
24471  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
24472  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
24473  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24474  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
24475  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
24476  AWGBFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
24477  AWGBFreqEntry.delete(0,"end")
24478  AWGBFreqEntry.insert(0,100.0)
24479  # AWG Phase or delay select sub frame
24480  # AWG Phase sub frame
24481  awg2phase = Frame( frame2r )
24482  awg2phase.pack(side=TOP)
24483  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
24484  awgbph.pack(side=LEFT, anchor=W)
24485  AWGBPhaseEntry = Entry(awg2phase, width=5, cursor='double_arrow')
24486  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
24487  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
24488  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24489  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
24490  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
24491  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
24492  AWGBPhaseEntry.delete(0,"end")
24493  AWGBPhaseEntry.insert(0,0)
24494  phaseblab = Label(awg2phase, text="Deg")
24495  phaseblab.pack(side=LEFT, anchor=W)
24496  # AWG duty cycle frame
24497  awg2dc = Frame( frame2r )
24498  awg2dc.pack(side=TOP)
24499  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
24500  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
24501  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
24502  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24503  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
24504  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
24505  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
24506  AWGBDutyCycleEntry.delete(0,"end")
24507  AWGBDutyCycleEntry.insert(0,50)
24508  duty2lab = Label(awg2dc, text="%")
24509  duty2lab.pack(side=LEFT, anchor=W)
24510  #
24511  bcompa = Checkbutton(frame2r, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)
24512  bcompa.pack(side=TOP)
24513 
24514  awgsync = Checkbutton(frame2r, text="Sync AWG", variable=AWGSync, command=BAWGSync)
24515  awgsync.pack(side=TOP)
24516  if ShowBallonHelp > 0:
24517  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
24518  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
24519  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
24520  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
24521  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
24522  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
24523  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
24524  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
24525 
24526 # input probe wigets
24527 prlab = Label(frame2r, text="Adjust Gain / Offset")
24528 prlab.pack(side=TOP)
24529 # Input Probes sub frame
24530 ProbeA = Frame( frame2r )
24531 ProbeA.pack(side=TOP)
24532 gain1lab = Button(ProbeA, text="CA-V", width=4, style="Ctrace1.TButton", command=ReSetAGO)
24533 gain1lab.pack(side=LEFT,fill=X)
24534 CHAVGainEntry = Entry(ProbeA, width=5, cursor='double_arrow')
24535 CHAVGainEntry.bind('<Return>', onTextKey)
24536 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
24537 CHAVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24538 CHAVGainEntry.bind("<Button-5>", onTextScroll)
24539 CHAVGainEntry.bind('<Key>', onTextKey)
24540 CHAVGainEntry.pack(side=LEFT)
24541 CHAVGainEntry.delete(0,"end")
24542 CHAVGainEntry.insert(0,1.0)
24543 CHAVOffsetEntry = Entry(ProbeA, width=5, cursor='double_arrow')
24544 CHAVOffsetEntry.bind('<Return>', onTextKey)
24545 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
24546 CHAVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24547 CHAVOffsetEntry.bind("<Button-5>", onTextScroll)
24548 CHAVOffsetEntry.bind('<Key>', onTextKey)
24549 CHAVOffsetEntry.pack(side=LEFT)
24550 CHAVOffsetEntry.delete(0,"end")
24551 CHAVOffsetEntry.insert(0,0.0)
24552 #
24553 ProbeB = Frame( frame2r )
24554 ProbeB.pack(side=TOP)
24555 gain2lab = Button(ProbeB, text="CB-V", width=4, style="Ctrace2.TButton", command=ReSetBGO)
24556 gain2lab.pack(side=LEFT,fill=X)
24557 CHBVGainEntry = Entry(ProbeB, width=5, cursor='double_arrow')
24558 CHBVGainEntry.bind('<Return>', onTextKey)
24559 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
24560 CHBVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24561 CHBVGainEntry.bind("<Button-5>", onTextScroll)
24562 CHBVGainEntry.bind('<Key>', onTextKey)
24563 CHBVGainEntry.pack(side=LEFT)
24564 CHBVGainEntry.delete(0,"end")
24565 CHBVGainEntry.insert(0,1.0)
24566 CHBVOffsetEntry = Entry(ProbeB, width=5, cursor='double_arrow')
24567 CHBVOffsetEntry.bind('<Return>', onTextKey)
24568 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
24569 CHBVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24570 CHBVOffsetEntry.bind("<Button-5>", onTextScroll)
24571 CHBVOffsetEntry.bind('<Key>', onTextKey)
24572 CHBVOffsetEntry.pack(side=LEFT)
24573 CHBVOffsetEntry.delete(0,"end")
24574 CHBVOffsetEntry.insert(0,0.0)
24575 #
24576 ProbeAI = Frame( frame2r )
24577 ProbeAI.pack(side=TOP)
24578 gainailab = Button(ProbeAI, text="CA-I", width=4, style="Ctrace3.TButton", command=ReSetAIGO)
24579 gainailab.pack(side=LEFT,fill=X)
24580 CHAIGainEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
24581 CHAIGainEntry.bind('<Return>', onTextKey)
24582 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
24583 CHAIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24584 CHAIGainEntry.bind("<Button-5>", onTextScroll)
24585 CHAIGainEntry.bind('<Key>', onTextKey)
24586 CHAIGainEntry.pack(side=LEFT)
24587 CHAIGainEntry.delete(0,"end")
24588 CHAIGainEntry.insert(0,1.0)
24589 CHAIOffsetEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
24590 CHAIOffsetEntry.bind('<Return>', onTextKey)
24591 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
24592 CHAIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24593 CHAIOffsetEntry.bind("<Button-5>", onTextScroll)
24594 CHAIOffsetEntry.bind('<Key>', onTextKey)
24595 CHAIOffsetEntry.pack(side=LEFT)
24596 CHAIOffsetEntry.delete(0,"end")
24597 CHAIOffsetEntry.insert(0,0.0)
24598 #
24599 ProbeBI = Frame( frame2r )
24600 ProbeBI.pack(side=TOP)
24601 gainbilab = Button(ProbeBI, text="CB-I", width=4, style="Ctrace4.TButton", command=ReSetBIGO)
24602 gainbilab.pack(side=LEFT,fill=X)
24603 CHBIGainEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
24604 CHBIGainEntry.bind('<Return>', onTextKey)
24605 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
24606 CHBIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24607 CHBIGainEntry.bind("<Button-5>", onTextScroll)
24608 CHBIGainEntry.bind('<Key>', onTextKey)
24609 CHBIGainEntry.pack(side=LEFT)
24610 CHBIGainEntry.delete(0,"end")
24611 CHBIGainEntry.insert(0,1.0)
24612 CHBIOffsetEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
24613 CHBIOffsetEntry.bind('<Return>', onTextKey)
24614 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
24615 CHBIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24616 CHBIOffsetEntry.bind("<Button-5>", onTextScroll)
24617 CHBIOffsetEntry.bind('<Key>', onTextKey)
24618 CHBIOffsetEntry.pack(side=LEFT)
24619 CHBIOffsetEntry.delete(0,"end")
24620 CHBIOffsetEntry.insert(0,0.0)
24621 # Add a pair of user entry wigets
24622 if EnableUserEntries > 0:
24623  UserEnt = Frame( frame2r )
24624  UserEnt.pack(side=TOP)
24625  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
24626  userentlab.pack(side=LEFT,fill=X)
24627  User1Entry = Entry(UserEnt, width=5, cursor='double_arrow')
24628  User1Entry.bind('<Return>', onTextKey)
24629  User1Entry.bind('<MouseWheel>', onTextScroll)
24630  User1Entry.bind("<Button-4>", onTextScroll)# with Linux OS
24631  User1Entry.bind("<Button-5>", onTextScroll)
24632  User1Entry.bind('<Key>', onTextKey)
24633  User1Entry.pack(side=LEFT)
24634  User1Entry.delete(0,"end")
24635  User1Entry.insert(0,0.0)
24636  User2Entry = Entry(UserEnt, width=5, cursor='double_arrow')
24637  User2Entry.bind('<Return>', onTextKey)
24638  User2Entry.bind('<MouseWheel>', onTextScroll)
24639  User2Entry.bind("<Button-4>", onTextScroll)# with Linux OS
24640  User2Entry.bind("<Button-5>", onTextScroll)
24641  User2Entry.bind('<Key>', onTextKey)
24642  User2Entry.pack(side=LEFT)
24643  User2Entry.delete(0,"end")
24644  User2Entry.insert(0,0.0)
24645 # add ADI logo Don't mess with this bit map data!
24646 ADIlogo = """
24647 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
24648 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
24649 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
24650 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
24651 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
24652 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
24653 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
24654 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
24655 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
24656 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
24657 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
24658 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
24659 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
24660 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
24661 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
24662 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
24663 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
24664 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
24665 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
24666 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
24667 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
24668 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
24669 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
24670 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
24671 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
24672 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
24673 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
24674 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
24675 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
24676 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
24677 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
24678 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
24679 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
24680 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
24681 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
24682 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
24683 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
24684 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
24685 """
24686 logo = PhotoImage(data=ADIlogo)
24687 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
24688 ADI1.pack(side=TOP)
24689 
24690 # Bottom Buttons
24691 # Voltage channel A
24692 if ButtonOrder == 1:
24693  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
24694  CHAlab.pack(side=LEFT)
24695 CHAsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHvpdiv, command=BCHAlevel)
24696 #CHAsb = ttk.Spinbox(frame3, cursor='double_arrow', style="Div.TSpinbox", values=CHvpdiv, command=BCHAlevel)
24697 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
24698 CHAsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24699 CHAsb.bind("<Button-5>", onSpinBoxScroll)
24700 CHAsb.pack(side=LEFT)
24701 CHAsb.delete(0,"end")
24702 CHAsb.insert(0,0.5)
24703 #
24704 if ButtonOrder == 0:
24705  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
24706  CHAlab.pack(side=LEFT)
24707 #
24708 if ButtonOrder == 1:
24709  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
24710  CHAofflab.pack(side=LEFT)
24711 CHAVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24712 CHAVPosEntry.bind("<Return>", BOffsetA)
24713 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24714 CHAVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24715 CHAVPosEntry.bind("<Button-5>", onTextScroll)
24716 CHAVPosEntry.bind('<Key>', onTextKey)
24717 CHAVPosEntry.pack(side=LEFT)
24718 CHAVPosEntry.delete(0,"end")
24719 CHAVPosEntry.insert(0,2.5)
24720 if ButtonOrder == 0:
24721  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
24722  CHAofflab.pack(side=LEFT)
24723 # Current channel A
24724 if ButtonOrder == 1:
24725  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
24726  CHAIlab.pack(side=LEFT)
24727 CHAIsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHipdiv, command=BCHAIlevel)
24728 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
24729 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24730 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
24731 CHAIsb.pack(side=LEFT)
24732 CHAIsb.delete(0,"end")
24733 CHAIsb.insert(0,50.0)
24734 if ButtonOrder == 0:
24735  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
24736  CHAIlab.pack(side=LEFT)
24737 #
24738 if ButtonOrder == 1:
24739  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
24740  CHAIofflab.pack(side=LEFT)
24741 CHAIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24742 CHAIPosEntry.bind("<Return>", BIOffsetA)
24743 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24744 CHAIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24745 CHAIPosEntry.bind("<Button-5>", onTextScroll)
24746 CHAIPosEntry.bind('<Key>', onTextKey)
24747 CHAIPosEntry.pack(side=LEFT)
24748 CHAIPosEntry.delete(0,"end")
24749 CHAIPosEntry.insert(0,0.0)
24750 if ButtonOrder == 0:
24751  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
24752  CHAIofflab.pack(side=LEFT)
24753 # Voltage channel B
24754 if ButtonOrder == 1:
24755  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
24756  CHBlab.pack(side=LEFT)
24757 CHBsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHvpdiv, command=BCHBlevel)
24758 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
24759 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24760 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
24761 CHBsb.pack(side=LEFT)
24762 CHBsb.delete(0,"end")
24763 CHBsb.insert(0,0.5)
24764 #
24765 if ButtonOrder == 0:
24766  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
24767  CHBlab.pack(side=LEFT)
24768 #
24769 if ButtonOrder == 1:
24770  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
24771  CHBofflab.pack(side=LEFT)
24772 CHBVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24773 CHBVPosEntry.bind("<Return>", BOffsetB)
24774 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24775 CHBVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24776 CHBVPosEntry.bind("<Button-5>", onTextScroll)
24777 CHBVPosEntry.bind('<Key>', onTextKey)
24778 CHBVPosEntry.pack(side=LEFT)
24779 CHBVPosEntry.delete(0,"end")
24780 CHBVPosEntry.insert(0,2.5)
24781 if ButtonOrder == 0:
24782  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
24783  CHBofflab.pack(side=LEFT)
24784 # Current channel B
24785 if ButtonOrder == 1:
24786  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
24787  CHBIlab.pack(side=LEFT)
24788 CHBIsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHipdiv, command=BCHBIlevel)
24789 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
24790 CHBIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24791 CHBIsb.bind("<Button-5>", onSpinBoxScroll)
24792 CHBIsb.pack(side=LEFT)
24793 CHBIsb.delete(0,"end")
24794 CHBIsb.insert(0,50.0)
24795 if ButtonOrder == 0:
24796  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
24797  CHBIlab.pack(side=LEFT)
24798 #
24799 if ButtonOrder == 1:
24800  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
24801  CHBIofflab.pack(side=LEFT)
24802 CHBIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24803 CHBIPosEntry.bind("<Return>", BIOffsetB)
24804 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24805 CHBIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24806 CHBIPosEntry.bind("<Button-5>", onTextScroll)
24807 CHBIPosEntry.bind('<Key>', onTextKey)
24808 CHBIPosEntry.pack(side=LEFT)
24809 CHBIPosEntry.delete(0,"end")
24810 CHBIPosEntry.insert(0,0.0)
24811 if ButtonOrder == 0:
24812  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
24813  CHBIofflab.pack(side=LEFT)
24814 #
24815 if ShowBallonHelp > 0:
24816  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
24817  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
24818  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
24819  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
24820  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
24821  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
24822  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
24823  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
24824  gain1lab_tip = CreateToolTip(gain1lab, 'Reset Gain to 1.0 and Offset to 0.0')
24825  gain2lab_tip = CreateToolTip(gain2lab, 'Reset Gain to 1.0 and Offset to 0.0')
24826  gainailab_tip = CreateToolTip(gainailab, 'Reset Gain to 1.0 and Offset to 0.0')
24827  gainbilab_tip = CreateToolTip(gainbilab, 'Reset Gain to 1.0 and Offset to 0.0')
24828 #
24829 root.geometry('+300+0')
24830 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
24831 #===== Initalize device ======
24832 if not numpy_found:
24833  root.update()
24834  showwarning("WARNING","Numpy not found!")
24835  root.destroy()
24836  exit()
24837 #
24838 BrdSel = IntVar(0)
24839 BoardStatus = IntVar(0)
24840 if pysmu_found:
24841  ConnectDevice()
24842  #session.hotplug_attach(ConnectDevice)
24843  #session.hotplug_detach(ConnectDevice)
24844  if EnableScopeOnly == 0:
24845  MakeAWGWindow() # build AWG window
24846  else:
24847  AWGScreenStatus.set(1)
24848  # root.update()
24849  BLoadConfig("alice-last-config.cfg") # load configuration from last session
24850  if LocalLanguage != "English":
24851  BLoadConfig(LocalLanguage) # load local language configuration
24852 # ================ Call main routine ===============================
24853  root.update() # Activate updated screens
24854 # Start sampling
24855  Analog_In()
24856 else:
24857  root.update()
24858  showwarning("WARNING","Pysmu not found!")
24859  root.destroy()
24860  exit()
24861 
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3.pyw:15811
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3.pyw:12271
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3.pyw:15669
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3.pyw:23055
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3.pyw:23279
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3.pyw:15559
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3.pyw:12838
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3.pyw:9598
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digital I/O screen.
Definition: alice-desktop-1.3.pyw:5606
alice-desktop-1.onRetAWGFiltB
def onRetAWGFiltB(event)
Definition: alice-desktop-1.3.pyw:21609
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3.pyw:22651
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3.pyw:5796
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3.pyw:1573
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3.pyw:5476
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3.pyw:21765
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3.pyw:15844
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3.pyw:17747
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3.pyw:23286
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3.pyw:9670
alice-desktop-1.TimeSeriesNoise
def TimeSeriesNoise(n, Fsample, mag, b=4)
Definition: alice-desktop-1.3.pyw:9928
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3.pyw:18130
alice-desktop-1.ToggleAWGAPhaseDelay
def ToggleAWGAPhaseDelay()
Definition: alice-desktop-1.3.pyw:10217
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3.pyw:17885
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3.pyw:2794
alice-desktop-1.shift_buffer
def shift_buffer(arr, num, fill_value=numpy.nan)
Function to left (-num) or right (+num) shift buffer and fill with a value returns same length buffer...
Definition: alice-desktop-1.3.pyw:4964
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3.pyw:3144
alice-desktop-1.OpenOtherTools
def OpenOtherTools()
Definition: alice-desktop-1.3.pyw:23332
alice-desktop-1.VAtoggle
def VAtoggle()
Definition: alice-desktop-1.3.pyw:15850
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3.pyw:9287
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3.pyw:9058
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3.pyw:18301
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3.pyw:13761
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3.pyw:19016
alice-desktop-1.ReSetBGO
def ReSetBGO()
Definition: alice-desktop-1.3.pyw:23308
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3.pyw:2836
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3.pyw:5612
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3.pyw:15517
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3.pyw:19722
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3.pyw:12333
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3.pyw:14703
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3.pyw:11570
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3.pyw:18181
alice-desktop-1.Analog_Chop_Time
def Analog_Chop_Time()
Definition: alice-desktop-1.3.pyw:4100
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3.pyw:19385
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3.pyw:23095
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3.pyw:11655
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3.pyw:8233
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3.pyw:22425
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3.pyw:13403
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3.pyw:12563
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3.pyw:19061
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3.pyw:3119
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3.pyw:21871
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3.pyw:19006
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3.pyw:21530
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3.pyw:9003
alice-desktop-1.fit_exp
def fit_exp(xs, ys)
Definition: alice-desktop-1.3.pyw:21748
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3.pyw:18971
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3.pyw:2854
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2044
alice-desktop-1.PlotPhAFromFile
def PlotPhAFromFile()
Definition: alice-desktop-1.3.pyw:16992
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3.pyw:20744
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3.pyw:3360
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3.pyw:3310
alice-desktop-1.AWGALoadWAV
def AWGALoadWAV()
Definition: alice-desktop-1.3.pyw:10398
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3.pyw:15498
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3.pyw:10949
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2642
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3.pyw:11083
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3.pyw:17961
alice-desktop-1.BAWGFiltBMath
def BAWGFiltBMath()
Definition: alice-desktop-1.3.pyw:21700
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3.pyw:21181
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3.pyw:10355
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3.pyw:3050
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3.pyw:11480
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3.pyw:17951
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3.pyw:22544
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3.pyw:11782
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3.pyw:20782
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3.pyw:2908
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3.pyw:12498
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3.pyw:3210
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3.pyw:22661
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3.pyw:13131
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3.pyw:10257
alice-desktop-1.RunScript
def RunScript()
Run a script file.
Definition: alice-desktop-1.3.pyw:1913
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3.pyw:18679
alice-desktop-1.ReSetAIGO
def ReSetAIGO()
Definition: alice-desktop-1.3.pyw:23316
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3.pyw:18159
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3.pyw:22236
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3.pyw:12828
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3.pyw:9039
alice-desktop-1.onRetAWGFiltA
def onRetAWGFiltA(event)
Definition: alice-desktop-1.3.pyw:21583
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3.pyw:11837
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3.pyw:13122
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3.pyw:2176
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3.pyw:17132
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3.pyw:13095
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3.pyw:5317
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3.pyw:5961
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3.pyw:18088
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2025
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3.pyw:15830
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3.pyw:13329
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3.pyw:18291
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3.pyw:17939
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3.pyw:12730
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3.pyw:3257
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3.pyw:2890
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3.pyw:12022
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3.pyw:11802
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3.pyw:5956
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3.pyw:17920
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3.pyw:2950
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3.pyw:10688
alice-desktop-1.Sine_Phase
def Sine_Phase()
Definition: alice-desktop-1.3.pyw:4901
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3.pyw:886
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3.pyw:15294
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3.pyw:9027
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3.pyw:9051
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3.pyw:22385
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3.pyw:2938
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3.pyw:22240
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3.pyw:1568
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3.pyw:5276
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3.pyw:9015
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3.pyw:17713
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3.pyw:2812
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3.pyw:12540
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3.pyw:13419
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3.pyw:17767
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3.pyw:13426
alice-desktop-1.Digital_RC_High_Pass
def Digital_RC_High_Pass(InBuff, TC1, Gain)
Digital RC filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3.pyw:4923
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3.pyw:18149
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3.pyw:22777
alice-desktop-1.BuildAWGBoxCarB
def BuildAWGBoxCarB()
Definition: alice-desktop-1.3.pyw:21616
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3.pyw:3221
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3.pyw:18228
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3.pyw:22671
alice-desktop-1.SchroederPhase
def SchroederPhase(Length, NrTones, Ampl)
Definition: alice-desktop-1.3.pyw:10024
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3.pyw:12727
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2585
alice-desktop-1.VBtoggle
def VBtoggle()
Definition: alice-desktop-1.3.pyw:15866
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3.pyw:1990
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3.pyw:15839
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3.pyw:22693
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3.pyw:18708
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3.pyw:13377
font
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3.pyw:20007
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3.pyw:2746
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3.pyw:21476
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3.pyw:13152
alice-desktop-1.BuildAWGBoxCarA
def BuildAWGBoxCarA()
Definition: alice-desktop-1.3.pyw:21590
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3.pyw:2976
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3.pyw:17987
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3.pyw:13320
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3.pyw:15643
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3.pyw:10614
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3.pyw:22643
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3.pyw:10729
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3.pyw:21187
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3.pyw:12717
alice-desktop-1.AWGBLoadCSV
def AWGBLoadCSV()
Definition: alice-desktop-1.3.pyw:11744
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3.pyw:21799
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3.pyw:21458
alice-desktop-1.MakePhAScreen
def MakePhAScreen()
Definition: alice-desktop-1.3.pyw:16309
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3.pyw:10229
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3.pyw:11608
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3.pyw:15284
alice-desktop-1.DestroyOOTwindow
def DestroyOOTwindow()
Definition: alice-desktop-1.3.pyw:23455
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3.pyw:880
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3.pyw:7339
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3.pyw:18222
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3.pyw:2699
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3.pyw:11877
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3.pyw:11683
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3.pyw:22466
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3.pyw:9674
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3.pyw:17913
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3.pyw:17048
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3.pyw:2215
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3.pyw:21914
alice-desktop-1.BrownNoise
def BrownNoise(N, mag)
Definition: alice-desktop-1.3.pyw:9992
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3.pyw:2394
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3.pyw:20651
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3.pyw:19697
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3.pyw:17899
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3.pyw:5868
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3.pyw:20474
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3.pyw:15549
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3.pyw:2783
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3.pyw:9698
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3.pyw:18996
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3.pyw:21033
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3.pyw:9606
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3.pyw:20826
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3.pyw:878
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3.pyw:5325
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3.pyw:18007
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3.pyw:2926
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3.pyw:17892
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3.pyw:3070
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3.pyw:12136
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3.pyw:2689
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3.pyw:5802
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3.pyw:17931
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3.pyw:12791
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3.pyw:18173
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3.pyw:17975
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3.pyw:3032
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3.pyw:13356
alice-desktop-1.DestroyPhAScreen
def DestroyPhAScreen()
Definition: alice-desktop-1.3.pyw:16076
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3.pyw:18109
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3.pyw:13173
alice-desktop-1.BRoll
def BRoll()
Toggel on/off Roll Sweep Mode.
Definition: alice-desktop-1.3.pyw:3133
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3.pyw:10765
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3.pyw:2932
alice-desktop-1.MakePhAWindow
def MakePhAWindow()
Definition: alice-desktop-1.3.pyw:15891
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3.pyw:10051
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3.pyw:22042
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3.pyw:21279
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3.pyw:13104
alice-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-desktop-1.3.pyw:22072
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3.pyw:3296
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3.pyw:2920
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.pyw:2286
alice-desktop-1.SettingsTextKey
def SettingsTextKey(event)
Definition: alice-desktop-1.3.pyw:22781
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3.pyw:9655
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3.pyw:20883
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3.pyw:885
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3.pyw:13298
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3.pyw:2097
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3.pyw:18234
alice-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-desktop-1.3.pyw:2210
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3.pyw:12751
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3.pyw:10276
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3.pyw:23292
alice-desktop-1.Analog_Phase_In
def Analog_Phase_In()
Definition: alice-desktop-1.3.pyw:3714
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3.pyw:1894
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3.pyw:3199
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3.pyw:13391
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3.pyw:18141
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3.pyw:3523
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3.pyw:5976
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3.pyw:22036
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3.pyw:13068
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3.pyw:2673
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2656
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3.pyw:13347
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3.pyw:21286
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3.pyw:11151
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3.pyw:9650
alice-desktop-1.BLoadAWGFiltB
def BLoadAWGFiltB()
Definition: alice-desktop-1.3.pyw:21676
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3.pyw:10389
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3.pyw:11252
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.pyw:2358
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2063
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3.pyw:20877
alice-desktop-1.BuildRejectFilter
def BuildRejectFilter(Order, Freject, Fsample)
Definition: alice-desktop-1.3.pyw:21717
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3.pyw:22536
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3.pyw:1906
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3.pyw:9203
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3.pyw:10068
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3.pyw:5934
alice-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-desktop-1.3.pyw:2758
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3.pyw:11981
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3.pyw:3349
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3.pyw:15542
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3.pyw:12879
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3.pyw:2663
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3.pyw:11531
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3.pyw:899
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3.pyw:21107
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3.pyw:18116
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3.pyw:9660
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3.pyw:17736
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3.pyw:18166
alice-desktop-1.BlueNoise
def BlueNoise(N, mag)
Definition: alice-desktop-1.3.pyw:9976
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3.pyw:10182
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3.pyw:3177
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3.pyw:14747
alice-desktop-1.IAtoggle
def IAtoggle()
Definition: alice-desktop-1.3.pyw:15874
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3.pyw:3245
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3.pyw:9065
alice-desktop-1.BSaveMuxData
def BSaveMuxData()
Save External Mux data to file.
Definition: alice-desktop-1.3.pyw:2110
alice-desktop-1.AddAWGBNoise
def AddAWGBNoise()
Definition: alice-desktop-1.3.pyw:12690
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3.pyw:18963
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3.pyw:2676
alice-desktop-1.IACapReset
def IACapReset()
Definition: alice-desktop-1.3.pyw:15511
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3.pyw:12924
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3.pyw:22297
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2080
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3.pyw:15686
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3.pyw:11702
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3.pyw:10375
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3.pyw:22223
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3.pyw:20918
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3.pyw:21501
alice-desktop-1.ReSetBIGO
def ReSetBIGO()
Definition: alice-desktop-1.3.pyw:23324
alice-desktop-1.CreateToolTip.configure
def configure(self, text)
Re Configure text string.
Definition: alice-desktop-1.3.pyw:927
alice-desktop-1.PinkNoise
def PinkNoise(N, mag)
Definition: alice-desktop-1.3.pyw:9961
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3.pyw:888
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3.pyw:10883
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3.pyw:12998
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3.pyw:12201
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3.pyw:5716
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3.pyw:9161
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3.pyw:5835
alice-desktop-1.Analog_Freq_In
def Analog_Freq_In()
Main SA and Bode loop Read from the stream and store the data into the arrays.
Definition: alice-desktop-1.3.pyw:4978
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3.pyw:2772
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3.pyw:877
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3.pyw:17600
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3.pyw:13194
alice-desktop-1.IACapZero
def IACapZero()
Definition: alice-desktop-1.3.pyw:15504
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3.pyw:17935
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3.pyw:11207
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3.pyw:11665
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3.pyw:17705
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3.pyw:2878
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3.pyw:11843
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3.pyw:17878
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3.pyw:18239
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3.pyw:21177
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3.pyw:9630
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3.pyw:2842
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3.pyw:2830
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3.pyw:3188
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3.pyw:18987
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3.pyw:10144
alice-desktop-1.VioletNoise
def VioletNoise(N, mag)
Definition: alice-desktop-1.3.pyw:10008
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3.pyw:2377
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3.pyw:5981
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3.pyw:1888
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3.pyw:9707
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3.pyw:17945
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3.pyw:881
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3.pyw:12818
alice-desktop-1.PhACheckBox
def PhACheckBox()
Definition: alice-desktop-1.3.pyw:3323
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3.pyw:17968
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3.pyw:18095
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3.pyw:9328
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3.pyw:10476
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3.pyw:2705
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3.pyw:10104
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3.pyw:17927
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3.pyw:879
alice-desktop-1.MakePhATrace
def MakePhATrace()
Definition: alice-desktop-1.3.pyw:16108
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3.pyw:11912
messagebox
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3.pyw:14114
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3.pyw:2902
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3.pyw:21479
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2649
alice-desktop-1.onAWGFiltAScroll
def onAWGFiltAScroll(event)
Definition: alice-desktop-1.3.pyw:21586
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3.pyw:23089
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3.pyw:18145
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3.pyw:10307
alice-desktop-1.BSavePhAData
def BSavePhAData()
Definition: alice-desktop-1.3.pyw:16956
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3.pyw:15490
alice-desktop-1.Analog_Roll_time
def Analog_Roll_time()
Definition: alice-desktop-1.3.pyw:3931
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3.pyw:891
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3.pyw:19365
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3.pyw:20959
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3.pyw:18102
alice-desktop-1.ReSetAGO
def ReSetAGO()
Definition: alice-desktop-1.3.pyw:23300
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3.pyw:21451
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3.pyw:13408
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3.pyw:10442
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3.pyw:9119
alice-desktop-1.UpdatePhATrace
def UpdatePhATrace()
Definition: alice-desktop-1.3.pyw:16099
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3.pyw:22277
alice-desktop-1.BAWGFiltAMath
def BAWGFiltAMath()
Definition: alice-desktop-1.3.pyw:21659
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3.pyw:21981
alice-desktop-1.BLoadAWGFiltA
def BLoadAWGFiltA()
Definition: alice-desktop-1.3.pyw:21635
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3.pyw:12801
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3.pyw:21454
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3.pyw:2866
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3.pyw:19706
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3.pyw:3269
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3.pyw:2679
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3.pyw:21568
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3.pyw:21507
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3.pyw:12400
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3.pyw:2578
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3.pyw:17616
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3.pyw:1761
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3.pyw:13366
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3.pyw:3233
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3.pyw:11020
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3.pyw:13183
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2604
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3.pyw:13384
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3.pyw:10823
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3.pyw:22162
alice-desktop-1.AWGBLoadWAV
def AWGBLoadWAV()
Definition: alice-desktop-1.3.pyw:11811
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3.pyw:2944
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3.pyw:9645
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3.pyw:13113
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3.pyw:10540
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3.pyw:9640
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3.pyw:1562
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3.pyw:5487
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3.pyw:10239
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3.pyw:1550
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3.pyw:5986
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3.pyw:9614
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3.pyw:13025
alice-desktop-1.BUserCustomPlotText
def BUserCustomPlotText()
Ask user to enter custom plot label string.
Definition: alice-desktop-1.3.pyw:2412
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3.pyw:3086
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3.pyw:18123
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3.pyw:20619
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3.pyw:2124
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3.pyw:17906
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3.pyw:14695
alice-desktop-1.VABtoggle
def VABtoggle()
Definition: alice-desktop-1.3.pyw:15858
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3.pyw:905
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3.pyw:9635
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3.pyw:20731
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3.pyw:15820
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3.pyw:17954
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3.pyw:21881
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3.pyw:9690
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3.pyw:20589
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3.pyw:12774
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3.pyw:20976
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3.pyw:9682
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3.pyw:12455
alice-desktop-1.Analog_Time_In
def Analog_Time_In()
Scope time main loop Read the analog data and store the data into the arrays.
Definition: alice-desktop-1.3.pyw:3645
alice-desktop-1.BSnapShotXY
def BSnapShotXY()
Take snap shot of displayed XY Traces.
Definition: alice-desktop-1.3.pyw:2266
alice-desktop-1.AWGBConfigMath
def AWGBConfigMath()
Definition: alice-desktop-1.3.pyw:11865
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3.pyw:10037
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3.pyw:9245
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3.pyw:9622
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3.pyw:17948
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3.pyw:12844
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3.pyw:3276
alice-desktop-1.time_points_from_freq
def time_points_from_freq(freq, fs=1, density=False)
Definition: alice-desktop-1.3.pyw:9910
alice-desktop-1.onAWGFiltBScroll
def onAWGFiltBScroll(event)
Definition: alice-desktop-1.3.pyw:21612
alice-desktop-1.Digital_RC_Low_Pass
def Digital_RC_Low_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3.pyw:4944
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3.pyw:21545
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3.pyw:13399
alice-desktop-1.SetChopMuxMode
def SetChopMuxMode()
Definition: alice-desktop-1.3.pyw:18934
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3.pyw:21027
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3.pyw:12808
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3.pyw:9665
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3.pyw:11320
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3.pyw:15676
ttk
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3.pyw:22785
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3.pyw:2235
alice-desktop-1.AWGALoadCSV
def AWGALoadCSV()
Definition: alice-desktop-1.3.pyw:10315
alice-desktop-1.AddAWGANoise
def AddAWGANoise()
Definition: alice-desktop-1.3.pyw:11453
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3.pyw:20567
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3.pyw:875
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3.pyw:17942
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3.pyw:15825
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3.pyw:21793
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3.pyw:3336
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3.pyw:11297
alice-desktop-1.AWGAConfigMath
def AWGAConfigMath()
Definition: alice-desktop-1.3.pyw:10464
alice-desktop-1.ToggleAWGBPhaseDelay
def ToggleAWGBPhaseDelay()
Definition: alice-desktop-1.3.pyw:11643
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Shift Time or vertical cursors if on or shift gated measurement cursors if enabled.
Definition: alice-desktop-1.3.pyw:9074
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3.pyw:22665
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3.pyw:22230
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2623
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3.pyw:1900
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3.pyw:18904
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3.pyw:21987
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3.pyw:2848
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3.pyw:18189
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3.pyw:10436
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3.pyw:13338
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3.pyw:22317
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3.pyw:895
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3.pyw:11517
alice-desktop-1.IBtoggle
def IBtoggle()
Definition: alice-desktop-1.3.pyw:15882
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3.pyw:14359
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3.pyw:5971
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3.pyw:3283
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3.pyw:19996
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3.pyw:933
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3.pyw:13423
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3.pyw:12077
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3.pyw:19375
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3.pyw:1556
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3.pyw:11736
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3.pyw:5966
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3.pyw:14685
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3.pyw:14699
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3.pyw:18701
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3.pyw:2423
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3.pyw:14873
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3.pyw:2914
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3.pyw:7064
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3.pyw:9729
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3.pyw:921
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3.pyw:21803
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3.pyw:18137
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3.pyw:12794
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
Definition: alice-desktop-1.3.pyw:4171
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3.pyw:20737
alice-desktop-1.TimeSeriesSingleTone
def TimeSeriesSingleTone(n, BinNum, Fsample, mag)
Definition: alice-desktop-1.3.pyw:9950
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3.pyw:18152
alice-desktop-1.PhACaresize
def PhACaresize(event)
Definition: alice-desktop-1.3.pyw:16085
alice-desktop-1.UpdatePhAAll
def UpdatePhAAll()
Definition: alice-desktop-1.3.pyw:16094
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3.pyw:21483
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3.pyw:5901
alice-desktop-1.UpdatePhAScreen
def UpdatePhAScreen()
Definition: alice-desktop-1.3.pyw:16103